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
2
votes
1 answer

Add Spearman's test P-value to ggplot using stat_fit_glance

I would like to add the p.value of the Spearman's correlation test on my ggplot. I have a data frame, Global.log.CD8.Density: head(Global.log.CD8.Density) ID Global.log.CD8.Density Signature Weight IM_186 0.124566 …
1
vote
2 answers

How to change the label on each quadrant of the scatterplot from count of observations into percent?

The code is: library(gginnards) library(ggpmisc) library(ggplot2) set.seed(4321) x <- 1:100 y <- rnorm(length(x), mean = 10) my.data <- data.frame(x, y) ggplot(my.data, aes(x, y)) + geom_quadrant_lines(colour = "blue", xintercept = 50,…
Robin
  • 325
  • 2
  • 12
1
vote
0 answers

Display line equation in subtitle of ggplot?

Below is the code for creating bulk hydrographs from a formatted .csv file in a network drive. stat_regline_equation(data=cont, aes(x,y)) allows me to print the continuous data line equation on the plot, but I was hoping I could add it to the…
1
vote
1 answer

Is it possible to extract slope and intercept from multiple fitted lines into a tibble?

I'm trying to compare the slope and intercept of many separate fitted lines and would like to extract this information from the equations that are shown using stat_poly_eq. I am able to plot all of the data and lines but since in my actual data I…
Vistho
  • 15
  • 4
1
vote
2 answers

stat_poly_eq() red text for significant p-value in facetwrap

I have a series of regressions wrapped into facet_wrap and I'm wondering whether it is possible to denote the text for significant pvals with red text or a "*" inside of the stat_poly_eq() [ggpmisc] function? Here is my sample code ggplot(my.data,…
Joshua Smith
  • 125
  • 6
1
vote
1 answer

Remove data to the left and right of local minima

I have a lot of measurements where I get data that looks something like this: # Generate example data x <- 1:100 y <- 100*(1-exp(-0.3*x)) x2 <- 101:200 y2 <- rev(y) df <- data.frame("x" = c(x, x2), "y" = c(y, y2)) df$x <- df$x +…
tlmoore
  • 125
  • 8
1
vote
0 answers

ggpmisc Error: package or namespace load failed for ‘ggpmisc’

I am trying to use the library ggpmisc and even though the installation went okey it gives me an error when I try to open the library. How can I solve it? install.packages("ggpmisc") WARNING: Rtools is required to build R packages but is not…
Dimitra K
  • 11
  • 2
1
vote
2 answers

Gamma(log) in stat_poly_eq

I'm having some trouble having stat_poly_eq print the correct formula within my plot. My current plot is plotted as follows. ggplot(DataSB,aes(x=Year,y=Kilos))+ geom_point(shape=21, size=3, color="black", fill="#E29578") + geom_smooth(method =…
Thije Zuidewind
  • 87
  • 1
  • 1
  • 7
1
vote
1 answer

R - How to make an expression containing a string and a dynamic variable bold in r/ggplot2

I am trying to make multiple facetted plots in r/ggplot2 that show R^2 and P values generated using the ggpmisc package, but format each line based on whether the P-value is below a certain number. I can successfully do this with a single character,…
E. Moore
  • 321
  • 1
  • 5
  • 11
1
vote
1 answer

Does ggpmisc::stat_poly_eq recompute the trend line math to get the labels?

library(ggplot2) library(dplyr) x <- 1:100 y <- (x + x^2 + x^3) + rnorm(length(x), mean = 0, sd = mean(x^3) / 4) my.data <- data.frame(x = x, y = y, group = c("A", "B"), facet = c("C", "D", "E", "F",…
1
vote
1 answer

How to add number of observations to label of plot (with grouping and faceting) using ggpmisc::stat_poly_eq

x <- 1:100 y <- (x + x^2 + x^3) + rnorm(length(x), mean = 0, sd = mean(x^3) / 4) my.data <- data.frame(x = x, y = y, group = c("A", "B"), facet = c("C", "D", "E", "F", "G"), y2 = y *…
1
vote
3 answers

Is there a way to add number of observations to plot label using ggpmisc::stat_poly_eq

x <- 1:100 y <- (x + x^2 + x^3) + rnorm(length(x), mean = 0, sd = mean(x^3) / 4) my.data <- data.frame(x = x, y = y, group = c("A", "B"), y2 = y * c(0.5,2), w = sqrt(x)) formula <- y…
1
vote
2 answers

Displaying regression lines based on P-value

I'm displaying linear regression models in plots using the ggpmisc package. I only want the regression line, p-value and r2-value to be showed in the plot if the p-value is less than 0.2. @Ricardo Semião e Castro helped me (thanks!) with a great…
Tiptop
  • 533
  • 5
  • 19
1
vote
1 answer

Adding an offset term to a glm formula in geom_smooth and stat_fit_tidy

I have a data.frame with counts per two groups in three clusters to which I'm fitting a logistic regression (binomial glm with a logit link function), and plotting it all using ggplot2's geom_bar and geom_smooth, and adding p-values using ggpmisc's…
dan
  • 6,048
  • 10
  • 57
  • 125
1
vote
0 answers

Calculating two LM in one plot using stat_poly_eq

I have calculated linear regression models between soil acetone emission and soil carbon content and plotted this in a graph like this: Instead of showing one regression model in the plots I would like to show one for organic and one for mineral…
Tiptop
  • 533
  • 5
  • 19