p <-
ggplot2::ggplot(mtcars) +
ggplot2::aes(mpg, disp) +
ggplot2::geom_smooth(method = "gam", formula = y ~ s(x, bs="cs"))
list(p)
executing the above code interactively in RStudio produces the following warning and then prints the graph with no smooth:
[[1]]
Warning message:
Computation failed in `stat_smooth()`:
no applicable method for 'smooth.construct' applied to an object of class "cs.smooth.spec"
This only happens when the plot is printed nested in a list. if I just try to print p
directly, it plots just fine.
If I run the same code in Rgui it works fine. I can replicate this on some but not all of my accessible copies of R. In particular the one big difference is that I am getting this error on my Windows 10 machines, but not on a Windows 7 machine.
Here is my session info:
- Session info ---------------------------------------------------------------------------------------------
setting value
version R version 4.0.5 (2021-03-31)
os Windows 10 x64
system x86_64, mingw32
ui RStudio
language (EN)
collate English_United States.1252
ctype English_United States.1252
tz America/Chicago
date 2021-04-19
- Packages -------------------------------------------------------------------------------------------------
package * version date lib source
assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.2)
cachem 1.0.4 2021-02-13 [1] CRAN (R 4.0.5)
callr 3.6.0 2021-03-28 [1] CRAN (R 4.0.5)
cli 2.4.0 2021-04-05 [1] CRAN (R 4.0.5)
colorspace 2.0-0 2020-11-11 [1] CRAN (R 4.0.5)
crayon 1.4.1 2021-02-08 [1] CRAN (R 4.0.5)
DBI 1.1.1 2021-01-15 [1] CRAN (R 4.0.5)
desc 1.3.0 2021-03-05 [1] CRAN (R 4.0.5)
devtools 2.4.0 2021-04-07 [1] CRAN (R 4.0.5)
digest 0.6.27 2020-10-24 [1] CRAN (R 4.0.5)
dplyr 1.0.3 2021-01-15 [1] CRAN (R 4.0.3)
ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
fansi 0.4.2 2021-01-15 [1] CRAN (R 4.0.5)
fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.0.5)
fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
generics 0.1.0 2020-10-31 [1] CRAN (R 4.0.5)
ggplot2 3.3.3 2020-12-30 [1] CRAN (R 4.0.5)
glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.3)
gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.2)
lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.5)
lifecycle 1.0.0 2021-02-15 [1] CRAN (R 4.0.5)
magrittr 2.0.1 2020-11-17 [1] CRAN (R 4.0.3)
Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.3)
memoise 2.0.0 2021-01-26 [1] CRAN (R 4.0.5)
mgcv 1.8-33 2020-08-27 [1] CRAN (R 4.0.5)
munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.2)
nlme 3.1-149 2020-08-23 [1] CRAN (R 4.0.5)
pillar 1.6.0 2021-04-13 [1] CRAN (R 4.0.5)
pkgbuild 1.2.0 2020-12-15 [1] CRAN (R 4.0.5)
pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.2)
pkgload 1.2.1 2021-04-06 [1] CRAN (R 4.0.5)
prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.2)
processx 3.5.1 2021-04-04 [1] CRAN (R 4.0.5)
ps 1.6.0 2021-02-28 [1] CRAN (R 4.0.5)
purrr 0.3.4 2020-04-17 [1] CRAN (R 4.0.2)
R6 2.5.0 2020-10-28 [1] CRAN (R 4.0.5)
remotes 2.3.0 2021-04-01 [1] CRAN (R 4.0.5)
rlang 0.4.10 2020-12-30 [1] CRAN (R 4.0.3)
rprojroot 2.0.2 2020-11-15 [1] CRAN (R 4.0.3)
scales 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.2)
testthat 3.0.2 2021-02-14 [1] CRAN (R 4.0.5)
tibble 3.1.0 2021-02-25 [1] CRAN (R 4.0.5)
tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2)
usethis 2.0.1 2021-02-10 [1] CRAN (R 4.0.5)
utf8 1.2.1 2021-03-12 [1] CRAN (R 4.0.5)
vctrs 0.3.7 2021-03-29 [1] CRAN (R 4.0.5)
withr 2.4.2 2021-04-18 [1] CRAN (R 4.0.5)
[1] C:/Users/Tyler/Documents/R/win-library/4.0
[2] C:/Program Files/R/R-4.0.5/library
When I try to debug what is happening (using debug(print)
), in Rstudio all the strings seem to print with different character encodings. For example, this is what I see in the debugged source window:
function (x, ...)
UseMethod("ÿþprintÿþ")