Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R within Rstudio cannot find rmarkdown package

I am trying to use rmarkdown, within Rstudio (0.98.953) on a PC, for the first time. I have upgraded to the latest versions of R (3.1.1) and R studio. The output from sessionInfo() is provided at the end of this question.

As I understand it rmarkdown should be included within Rstudio. However, when I select to create a markdown document in Rstudio, a dialog box pops up saying additional packages need to be installed. The installation of rmarkdown always then fails, with the following message:

Installing package into '\\cfsk18.campus.gla.ac.uk/SSD_Home_Data_X/jm383x/My        Documents/R/win-library/3.1'
(as 'lib' is unspecified)
* installing *source* package 'rmarkdown' ...
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return =     TRUE) :
  there is no package called 'rmarkdown'
Error: loading failed
Execution halted
*** arch - x64
Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return =     TRUE) :
  there is no package called 'rmarkdown'
Error: loading failed
Execution halted
ERROR: loading failed for 'i386', 'x64'
* removing '\\cfsk18.campus.gla.ac.uk/SSD_Home_Data_X/jm383x/My Documents/R/win-    library/3.1/rmarkdown'
Warning messages:
1: running command '"C:/PROGRA~1/R/R-31~1.1/bin/x64/R" CMD INSTALL -l "\\cfsk18.campus.gla.ac.uk\SSD_Home_Data_X\jm383x\My Documents\R\win-library\3.1"     "C:/PROGRA~1/RStudio/R/packages/rmarkdown_0.2.49_047a80058bb4ef0b142196013d1c4dd8870d4dd9.tar.gz"' had status 1 
2: In utils::install.packages("C:/Program     Files/RStudio/R/packages/rmarkdown_0.2.49_047a80058bb4ef0b142196013d1c4dd8870d4dd9.tar.gz",      :
  installation of package     'C:/PROGRA~1/RStudio/R/packages/rmarkdown_0.2.49_047a80058bb4ef0b142196013d1c4dd8870d4dd9.tar.gz' had non-zero exit status

I assume this is something to do with using a managed desktop in my place of work. However this is not usually a problem as far fewer restrictions are placed on these machines than is usually the case, and all other packages, software etc tend to work.

I have also tried installing rmarkdown directly from github. Again the installer cannot identify the package rmarkdown itself.

What is likely to be the cause of the error?

SessionInfo output:

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

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     

loaded via a namespace (and not attached):
[1] tools_3.1.1

Attempt to install directly from github repo:

devtools::install_github("rstudio/rmarkdown")
Installing github repo rmarkdown/master from rstudio
Downloading master.zip from https://github.com/rstudio/rmarkdown/archive/master.zip
Installing package from C:\Users\jm383x\AppData\Local\Temp\RtmpINmLRv/master.zip
Installing rmarkdown
Installing dependencies for rmarkdown:
httpuv
Installing package into ‘\\cfsk18.campus.gla.ac.uk/SSD_Home_Data_X/jm383x/My     Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.1/httpuv_1.3.0.zip'
Content type 'application/zip' length 857357 bytes (837 Kb)
opened URL
downloaded 837 Kb

package ‘httpuv’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Users\jm383x\AppData\Local\Temp\RtmpINmLRv\downloaded_packages
"C:/PROGRA~1/R/R-31~1.1/bin/x64/R" --vanilla CMD INSTALL  \
  "C:\Users\jm383x\AppData\Local\Temp\RtmpINmLRv\devtoolscec10833677\rmarkdown-master"       \
  --library="\\cfsk18.campus.gla.ac.uk/SSD_Home_Data_X/jm383x/My Documents/R/win-   library/3.1" --install-tests 

* installing *source* package 'rmarkdown' ...
** R
** inst
** tests
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
*** arch - i386
    Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return =     TRUE) :
      there is no package called 'rmarkdown'
    Error: loading failed
    Execution halted
    *** arch - x64
     Warning in library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE) :
  there is no package called 'rmarkdown'
    Error: loading failed
    Execution halted
    ERROR: loading failed for 'i386', 'x64'
* removing '\\cfsk18.campus.gla.ac.uk/SSD_Home_Data_X/jm383x/My Documents/R/win-      library/3.1/rmarkdown'
like image 232
JonMinton Avatar asked Jul 14 '14 09:07

JonMinton


3 Answers

Try running this code to get the latest version of the rmarkdown package, which should solve the issue:

install.packages("rmarkdown", repos = "https://cran.revolutionanalytics.com")

The issue is that the RStudio IDE looks at a static CRAN snapshot that was taken before the rmarkdown package was updated. For more information, see this link: https://groups.google.com/forum/#!topic/rropen/Kgg8z6FF40I

like image 149
Ryan Chase Avatar answered Sep 18 '22 11:09

Ryan Chase


I wonder if the problem is the space in the path shown for the --library option to your install_github command. I know you say you've installed packages OK before, but my setup sounds just slike yours and rmarkdown works for me. I have RStudio 0.98.953 on Win7, which is a very locked-down corporate machine. I've coerced it into letting me install R packages by setting the env variable R_LIBS to my network home drive. Loading packages is slow, but I have no choice because I cannot write to the C: drive. So, my install_github command has --library="H:/Rlib". Your path has "My Documents" embedded in it. I'm not positive that's the problem, but my github installation of "rstudio/rmarkdown" did succeed. When I do File -> New File -> R Markdown, followed by a press of the "Knit HTML" button, that also completes successfully.

The RStudio github page https://github.com/rstudio/rmarkdown#installation makes it sound like manual installation of rmarkdown in RStudio isn't required, but I did it anyway because I don't always use R through RStudio. Sorry, but I didn't test RStudio by making a new R Markdown file before I manually installed the package.

The RStudio blog post http://blog.rstudio.org/2014/06/18/r-markdown-v2/ says clearly that the rmarkdown package is intended to replace the previous markdown package. The rmarkdown package does not yet appear to be on CRAN, so install_github is necessary.

like image 29
Brian Doherty Avatar answered Sep 21 '22 11:09

Brian Doherty


The best that worked for me is to quit Rstuido, then install rmarkdown package in the base R (not any IDE) and restarting Rstudio.

I am on Windows 10, R 3.3.1, Rstudio Version 0.99.903

like image 35
BKS Avatar answered Sep 22 '22 11:09

BKS