Questions tagged [ggpmisc]

The ggpmisc tag should be used for questions related to the use of R package 'ggpmisc'.

The ggpmisc tag should be used for questions related to the use of R package 'ggpmisc'. Bug reports and requests for enhancements should not be posted here, but instead informed to the maintainer by raising an issue at https://bitbucket.org/aphalo/ggpmisc/issues.

The 'ggpmisc' R package is available through CRAN, and includes detailed documentation. This same documentation is also available in HTML format at http://docs.r4photobiology.info/ggpmisc and can be looked at without need to install the package. The source code of the package is in a public Git repository at https://bitbucket.org/aphalo/ggpmisc.

Functions are provided to convert time series objects into data frames or tibbles suitable for plotting with R package 'ggplot2'. To complement these functions ggplot() methods for "ts" and "xts" classes are also defined.

Different statistics, geometries and functions add facilities for labelling peaks and valleys, generating labels for fitted models including polynomial equations, highlighting deviations from a model fit, and for filtering-out regions of plot panels with high densities of observations (with stats designed to work nicely together with R package 'ggrepel').

Geometries for adding layers with inset tables, ggplots or 'grid' grobs are also defined together with versions of geom_text and geom_label that use 'grid' npc coordinates instead of data coordinates supported by new aesthetics npcxand npcy and corresponding scales.

81 questions
0
votes
1 answer

Pull out Regression Eqn from ggplot

Here is a reproducible example of my problem: library(ggplot2) library(dplyr) library(ggpmisc) df <- mtcars %>% filter(cyl==4) ggplot(mtcars,aes(x=disp,y=hp))+ geom_point() + stat_poly_line() + stat_poly_eq(use_label(c("eq"))) I want to be…
user2813606
  • 797
  • 2
  • 13
  • 37
0
votes
0 answers

How can I adjust text formatting in stat_poly_eq?

I'm trying to adjust an equation formatting which is shown while using ggplot2 (ver. 3.3.5) and ggpmisc (ver. 0.5.1) with stat_poly_eq. All works just fine but for the case when the coefficients in the equation became small: the "minus" sign in the…
densz
  • 31
  • 3
0
votes
0 answers

How to automatically add R^2 to a graph with facet wrap using ggplot2?

I am trying to add R^2 values to each facet in a ggplot2 graph. This is the code I have so far and this is what the graph looks like currently. ggplot(BB_new, aes(x=Date, y=pH, color=Treatment)) + geom_point(pch=19, size=1,alpha = 1)+ …
0
votes
1 answer

How does lm() work when one axis is logarithmic?

I've tried fitting a linear equation to data with a logarithmic y axis a couple different ways. I seem to get the correct line and equation when I use stat_poly_line and stat_poly_eq. (See example with…
Vistho
  • 15
  • 4
0
votes
1 answer

Trying to graph different linear regression models with ggplot and equation labels

Here is the dput for the dataset I'm working with: structure(list(X = c(18, 19, 20, 17, 8, 15, 14, 16, 18, 14, 16, 13, 16, 17, 10, 18, 19, 25, 18, 13, 18, 16, 11, 17, 15, 18, 19, 16, 20, 17, 8, 18, 15, 14, 18, 14, 16, 13, 16), Y = c(15, 13, 14,…
Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
0
votes
1 answer

How can I scale a plot without affecting the data that is fit?

I have some data that is a bit crowded close to zero. I would thus like to use a logarithmic scale for the axes to get a clearer impression of those points. However, when I do this and I use the very convenient ggpmisc::stat_poly_line function, the…
Midnighter
  • 3,771
  • 2
  • 29
  • 43
0
votes
2 answers

How to add shapes for another factor in ggplot for regression model

I am trying to add shape to a regression model. Here is the example: library(ggpubr) data(iris) iris$ran <- as.factor(rep(c(1:2), each = 75)) fit <- lm(Sepal.Length ~ Petal.Width+Species+ran, data = iris) ggplot(fit$model, aes_string(x =…
AST
  • 57
  • 1
  • 6
0
votes
1 answer

ggpmisc::stat_poly_eq crashes when one group does not have enough data points

library(ggpmisc) data <- mpg table(data$class) data$class[mpg$class=="2seater"] <- c(rep("2seater", 1), rep("compact", 4)) formula <- y ~ x + I(x^2) ggplot(data, aes(x = displ, y = hwy, color = class)) + geom_point() + geom_smooth(method = "lm",…
0
votes
1 answer

Discrepancy between gggmisc and broom packages in LM estimates

I'm trying to extract slope values from a number of linear regression models. I plotting acetone emission against water content on different days. I have these graphs and models I have tried to extract the slope values using this…
Tiptop
  • 533
  • 5
  • 19
0
votes
1 answer

overlay of the legend of the estimated lines using the function stat_poly_eq

I adjusted different models considering the response variable (massaseca) as a function of (tempo) for each treatment level (teor) using the ggplot2 function combined with the stat_poly_eq function. However, as can be seen in the graph below, the…
user55546
  • 37
  • 1
  • 15
0
votes
0 answers

R get linear regression equation for boxplots

I didn´t found a sufficient answer in this forum yet, so I decided to raise my own question. I want to get the linear regression equation of a linear fit from a boxplot. I have this data: library(ggplot2) data <- structure(list(x = structure(c(1L,…
basti41a
  • 153
  • 1
  • 6
0
votes
0 answers

Shiny-R: Display regression equation by groups under ggplot

I´ve looked for similiar questions, but wasn´t very sucessful. I want to display my regression equations / coefficients under my ggplot as a text output. Right now, I can display the regression equation in the graph with ggpmisc::stat_poly_eq(),…
basti41a
  • 153
  • 1
  • 6
0
votes
2 answers

Adding trend lines across groups and setting tick labels in a grouped violin plot or box plot

I have xy grouped data that I'm plotting using R's ggplot2 geom_violin adding regression trend lines: Here are the data: library(dplyr) library(plotly) library(ggplot2) set.seed(1) df <- data.frame(value =…
dan
  • 6,048
  • 10
  • 57
  • 125
0
votes
2 answers

Plotting multiple polynomial and linear regression lines on the same scatter plot

I've got a problem with the following regression models. I want to get two polynomial regression lines and one linear regression line on the same scatter plot. In addition, i want to show the equations for the three different models on the same…
Xaviermoros
  • 131
  • 10
0
votes
1 answer

ggpmisc clearing up confusion about summarized data lengths

I am getting this error message "Error in data.frame(mean_Flow, dates) : arguments imply differing number of rows: 84, 30274" and I know it is confused about which date function I want it to pull but I'm not sure how to clear it up. I want the…
Kelsey
  • 41
  • 2