Running this code causes the plot viewer to stop functioning. It worked for me a week ago, and although I've updated to R4, the same crash occurs on RStudio cloud when I've tested it there today (SessionInfo says cloud is running R3.6) See cloud project here (https://rstudio.cloud/project/1219353).
#ggsave of ggplot crashes viewer
# install.packages("tidyverse")
# install.packages("ggalt")
library(tidyverse)
library(ggalt)
plot(cars)
#This Works
p <- ggplot(mtcars, aes(x=hp, y=mpg, group = cyl, colour=cyl))+
geom_point(size=1)+
theme(legend.position = "none")
p
ggsave("my plot 1.png", plot = p)
#This crashes
p <- ggplot(mtcars, aes(x=hp, y=mpg, group = cyl, colour=cyl))+
geom_point(size=1)+
theme(legend.position = "none") +
geom_xspline(spline_shape = -0.5, size=0.5, linetype=2) #adding this line causes ggsave not to work, and crashes plot viewer
p
ggsave("my plot 2.png", plot = p)
sessionInfo()
> sessionInfo()
R version 4.0.0 (2020-04-24)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 18363)
Matrix products: default
locale:
[1] LC_COLLATE=English_New Zealand.1252 LC_CTYPE=English_New Zealand.1252 LC_MONETARY=English_New Zealand.1252
[4] LC_NUMERIC=C LC_TIME=English_New Zealand.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggalt_0.4.0 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5 purrr_0.3.4 readr_1.3.1 tidyr_1.0.2
[8] tibble_3.0.1 ggplot2_3.3.0 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] tidyselect_1.0.0 haven_2.2.0 lattice_0.20-41 colorspace_1.4-1 vctrs_0.2.4 generics_0.0.2
[7] rlang_0.4.5 pillar_1.4.3 glue_1.4.0 withr_2.2.0 DBI_1.1.0 dbplyr_1.4.3
[13] RColorBrewer_1.1-2 modelr_0.1.6 readxl_1.3.1 lifecycle_0.2.0 munsell_0.5.0 gtable_0.3.0
[19] cellranger_1.1.0 rvest_0.3.5 labeling_0.3 extrafont_0.17 fansi_0.4.1 Rttf2pt1_1.3.8
[25] broom_0.5.6 Rcpp_1.0.4.6 KernSmooth_2.23-16 scales_1.1.0 backports_1.1.6 jsonlite_1.6.1
[31] farver_2.0.3 fs_1.4.1 proj4_1.0-10 digest_0.6.25 hms_0.5.3 packrat_0.5.0
[37] stringi_1.4.6 ash_1.0-15 grid_4.0.0 cli_2.0.2 tools_4.0.0 magrittr_1.5
[43] maps_3.3.0 extrafontdb_1.0 crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.0 MASS_7.3-51.5
[49] xml2_1.3.1 reprex_0.3.0 lubridate_1.7.8 assertthat_0.2.1 httr_1.4.1 rstudioapi_0.11
[55] R6_2.4.1 nlme_3.1-147 compiler_4.0.0