sudo su – -c

Published by onesixx on

http://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/
Note 6.1: Important note re: installing R packages

devtools

package ‘curl’ successfully unpacked and MD5 sums checked
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
Package libcurl was not found in the pkg-config search path.
Perhaps you should add the directory containing `libcurl.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libcurl' found
sudo apt-get install libcurl4-openssl-dev libssl-dev 

 

 

 

 

sudo su - -c "R -e \"install.packages('devtools', repos='http://cran.rstudio.com/')\""

Note that instead of launching R and installing the packages from R,
I’m doing it from the terminal with sudo su - -c "R ...". Why?
Because if you log into R and install packages, by default they will be installed in your personal library and will only be accessible to the current user (dean in this case).
By running the command the way I do above, it installs the packages as the root user, which means the packages will be installed in a global library and will be available to all users.

As a demonstration, launch R (simply run R) and run .libPaths().
This will show you all the locations where R will search for a package, and the first one is where a new package will get installed. You’ll probably notice that the first entry, where packages will get installed, is a path under the current user’s home (for me it’s /home/dean/R/x86_64-pc-linux-gnu-library/3.2). From now on, whenever you want to install a package for the whole system, you should either log in as root and intall the package, or use the above command. To install an R package for just one user, it’s ok to proceed as normal and just install the package when you’re logged in as the intended user.

 

ex) rmarkdown을 설치했는데도 아래와 같은 에러가 발생할때

Error in eval(expr, envir, enclos) : 
  You are attempting to load an rmarkdown file, but the 
rmarkdown package was not found in the library. Ensure that 
rmarkdown is installed and is available in the Library of the 
user you're running this application as.
Calls: local -> eval.parent -> eval -> eval -> eval -> eval
Execution halted

 

sudo su - -c "R -e \"install.packages('rmarkdown', repos='http://cran.rstudio.com/')\""

 

Categories: R Basic

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x