Closed emmansh closed 3 months ago
This error is caused by an attempt to compute a confidence interval with too few observations or NAs. Please, see #60. A fix is implemented in the main branch here. Can be installed from R-Universe.
library(ggplot2)
library(ggpmisc)
#> Loading required package: ggpp
#> Registered S3 methods overwritten by 'ggpp':
#> method from
#> heightDetails.titleGrob ggplot2
#> widthDetails.titleGrob ggplot2
#>
#> Attaching package: 'ggpp'
#> The following object is masked from 'package:ggplot2':
#>
#> annotate
df <-
data.frame(foo = c(-16, -15, -11, -10, -7, -6, -4, -3),
bar = c(NA, 12, 18, -34, 37, -18, -26, 36))
length(df$foo)
#> [1] 8
length(df$bar)
#> [1] 8
df |>
ggplot(aes(x = foo, y = bar)) +
stat_poly_line() +
stat_poly_eq(use_label(c("eq", "R2")))
#> Warning: Removed 1 row containing non-finite outside the scale range
#> (`stat_poly_line()`).
#> Warning: Removed 1 row containing non-finite outside the scale range
#> (`stat_poly_eq()`).
#> Warning in ci_f_ncp(stat, df1 = df1, df2 = df2, probs = probs): Upper limit
#> outside search range. Set to the maximum of the parameter range.
#> Warning in compute_group(...): CI computation error: Error in check_output(cint, probs = probs, parameter_range = c(0, 1)): out[1] <= out[2] is not TRUE
Created on 2024-05-27 with reprex v2.1.0
or with the CRAN version of 'ggpmisc' or to silence the error message, please add rsquared.conf.level = NA
to the call.
library(ggplot2)
library(ggpmisc)
#> Loading required package: ggpp
#> Registered S3 methods overwritten by 'ggpp':
#> method from
#> heightDetails.titleGrob ggplot2
#> widthDetails.titleGrob ggplot2
#>
#> Attaching package: 'ggpp'
#> The following object is masked from 'package:ggplot2':
#>
#> annotate
df <-
data.frame(foo = c(-16, -15, -11, -10, -7, -6, -4, -3),
bar = c(NA, 12, 18, -34, 37, -18, -26, 36))
length(df$foo)
#> [1] 8
length(df$bar)
#> [1] 8
df |>
ggplot(aes(x = foo, y = bar)) +
stat_poly_line() +
stat_poly_eq(use_label(c("eq", "R2")), rsquared.conf.level = NA)
#> Warning: Removed 1 row containing non-finite outside the scale range
#> (`stat_poly_line()`).
#> Warning: Removed 1 row containing non-finite outside the scale range
#> (`stat_poly_eq()`).
Created on 2024-05-27 with reprex v2.1.0
Already posted in Stack Overflow (here), but I believe this is a bug so opening it here.
I get the following error with
stat_poly_eq()
:Example Data
Created on 2024-05-26 with reprex v2.0.2
Searching around I found this answer from Stack Overflow. Indeed, using
ggpubr
gives the expected output:Created on 2024-05-26 with reprex v2.0.2