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
1
vote
1 answer

correct positioning of ggplot insets with ggpmisc in facet

How can I flexibly position an inset using ggpmisc without changing the width and height of the inset itself? library(tidyverse) library(sf) library(ggpmisc) #data nc <- st_read(system.file("gpkg/nc.gpkg", package = "sf"), quiet = TRUE) %>% …
user63230
  • 4,095
  • 21
  • 43
1
vote
0 answers

"Error in f(...) : argument "table.theme" is missing, with no default" when using ggpmisc's annotate function for a table object

library(ggpmisc) ggplot(Table, aes(x = Date, y = Value, group = Group)) + geom_line(size = 0.2) + scale_y_continuous("Value") + scale_x_date("Date", breaks = "4 years", labels = date_format("%Y"), expand = expansion(mult = 0, add = 0)) + …
1
vote
1 answer

How to format R2 and RMSE table added to a ggplot?

I am trying to add R2 and RMSE to a facetted ggplot. I am using the following code for that library(caret) library(tidyverse) library(ggpmisc) summ <- iris %>% group_by(Species) %>% summarise(Rsq = R2(Sepal.Length, Petal.Length), …
UseR10085
  • 7,120
  • 3
  • 24
  • 54
1
vote
1 answer

Adding a blocking factor in stat_poly_eq()

I'm fixing a linear regression with lm() like model<-lm(y~x+a, data=dat) where a is a blocking variable with multiple factor levels. summary(model) Call: lm(formula = y ~ x, data = dat) Residuals: Min 1Q Median 3Q Max…
Anke
  • 527
  • 1
  • 6
  • 19
1
vote
1 answer

How to place stat_poly_eq labels outside of facet graph?

I have a facet graph and it's a pain having to tweak each individual r-square label, this includes moving them left to right, up and down, big and small. One may be larger than the other or hidden away at the bottom of the graph whilst the others…
Lime
  • 738
  • 5
  • 17
1
vote
1 answer

facet_wrap text labelling issues with stat_fit_glance

I am wondering why the text is trending higher in the plots... it won't stay put with the facet_wrap or facet_grid. In a more complex dataset plot, the text is illegible because of the overlap. Below is data and code to reproduce the plot and…
ecology
  • 606
  • 3
  • 9
  • 29
1
vote
2 answers

Plotting MA / SMA / RMA regressions lines (smatr or lmodel2 packages) into ggplot

I would be very grateful for advise on how to plot Standardised Major Axis (SMA) regressions lines into a faceted ggplot. I used the following code: Run the SMA analysis and create a data frame with the SMA reg line coefficients (intercept and…
Dodo
  • 17
  • 3
1
vote
2 answers

Coefficients per facet with output.type="numeric" in ggpmisc::stat_poly_eq

ggpmisc::stat_poly_eq has an option output.type = "numeric" allowing to get the estimates of the parameters of the fitted model. Below is my attempt to use it with facet_wrap. I get a different R² per facet but the coefficients are the same in the…
Stéphane Laurent
  • 75,186
  • 15
  • 119
  • 225
1
vote
2 answers

Script won't run (Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type

I have run the script below numerous times and it has worked until this morning, when it suddenly produced the error message: (Error in terms.formula(formula, data = data) : 'data' argument is of the wrong type. I have not changed anything and…
Dag
  • 569
  • 2
  • 5
  • 20
1
vote
1 answer

Add p-value to ggplot without creating a lm-obejct separately

I have to create a large (100+) number of ggplots of linear models. I would like to add the p-value (and potentially R2) to each plot. I know it is possible to do this using ggpmisc. Here, I employ stat_fit_glance to add the p-value. My 'problem' is…
LHAndersen
  • 109
  • 1
  • 9
1
vote
2 answers

Plot scatter plot when values are wrongly paired

I am trying to create some correlation plots based of a data frame that I created using dplyr's spread() function. When I used the spread function, it created NAs in the new data frame. This makes sense because the data frame had concentration…
NBE
  • 641
  • 2
  • 11
  • 33
1
vote
1 answer

ggpmisc::stat_poly_eq() does not consider weighting by a variable

How can I get ggpmisc::stat_poly_eq() to take into account weighting by a variable? I don't see in the documentation a parameter to include weight as it exists in geom_smooth and if I try to force it within aes() it results in 'Warning: Ignoring…
silver
  • 15
  • 7
0
votes
1 answer

Show sqrt(y) ~ assign(sqrt(x)) relationship with `stat_poly_eq`, `stat_fit_tb` or `stat_fit_tidy`

require(utils) x = runif(n = 10, min = 0.2, max = 1) y = rnorm(n = 10, mean = 2.5, sd = .5) df = expand.grid(x = x, y = y) I used the code below to plot the sqrt(y) ~ assign(sqrt(x)) relationship and show the equation on the graph.…
hnguyen
  • 772
  • 6
  • 17
0
votes
0 answers

problem plotting linear regression equation with ggpmisc in R studio

I am trying to plot linear regression and display corresponding equations and R squared. I used the #following code: ch= factor (rep(c("c1", "c2", "c3", "c4"),3, each=4)) ch tr= factor ((rep(c("dd", "ld", "dc"), each=16)), levels=…
s_pgn
  • 11
  • 1
0
votes
0 answers

How do I change the start of my trendline to be 0 using ggpmisc stat_poly_line?

I have a scatter plot in R ggplot2 and I am using ggpmisc's stat_poly_line to draw a trendline and calculate R2, my problem is that due to my data, my trendline starts at a value different from 0 and I want to force the trendline to start at 0…
Nomye
  • 3
  • 2