问题
I'm using R.3.3.1 in RStudio 0.99.903 on a work PC.
I'm having the same error message when trying to use both ggplot2 and tidytext: although I managed to install both packages, when i launch them i get this error message:
Error : package ‘grid’ does not have a namespace
At first i thought this meant grid was missing but i read that it's now part of base so i don't understand why it doesn't load when i run library(grid)... Adding to my confusion is the fact that i can only see gridBase and gridExtra in my list of packages, not grid. And when i try library(gridBase) i also get the same "Error : package ‘grid’ does not have a namespace" message.
Here's my session info:
sessionInfo() R version 3.3.1 (2016-06-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252 LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] stringr_1.0.0 tidyr_0.5.1 scales_0.4.0 lubridate_1.5.6 purrr_0.2.2 dplyr_0.5.0
loaded via a namespace (and not attached):
[1] Rcpp_0.12.6 assertthat_0.1 R6_2.1.2 plyr_1.8.4 DBI_0.4-1 magrittr_1.5 stringi_1.1.1
[8] lazyeval_0.2.0 tools_3.3.1 munsell_0.4.3 colorspace_1.2-6 tibble_1.1
i've looked everywhere online and tried various approaches (using an older version of R, changing the default CRAN in my RStudio global options, unticking "use internet explorer library proxy", remove and re-install the packages from R not RStudio, both GUI and Shell...) but nothing works...
回答1:
This happened to me after unloading packages that I thought I was not using. "Grid" was a package listed in the Packages window in Rstudio and I deleted it along with about 20 others. Not having "grid" prevented loading "ggplot2" which in turn prevented loading "rstan".
I recovered by reinstalling R, presuming that such a fundamental package must be part of the base install since it was not on CRAN. After reinstall, the error related to "grid" disappeared, but the package "scales" was now identified as missing. "Scales" was on CRAN and easily loaded. library(ggplot2) appear to be working again.
来源:https://stackoverflow.com/questions/38897652/error-package-grid-does-not-have-a-namespace