run R as administrator

Viewed 25967

I was using my own laptop to install R and I found that it only has one library. Evne though this library is still read only, everytime when I use Rstudio: install.packages("abc"), I can see that the new packages are stored automatically into that read only library folder.

In my office's desktop, I "believe" I also have administrator role, as I can install and remove anything (by far). I download the latest version of R and I right click the R-3.4.1-win.exe, there is an item "run as administrator", then it is installed in my desktop. However, when I use R studio to install new packages as in my laptop, it always automatically create a personal folder to store the new packages. I don't know why. Is that a way to only have one folder for library? I also tried on the desktop in the plain R mode (without using Rstudio). When I want to install new packages, it always says

Warning in install.packages("devtools") :
  'lib = "C:/Program Files/R/R-3.4.1/library"' is not writable

And there is a window pops up to ask me "would you like to create a personal folder?" And if I say no, then

Error in install.packages("devtools") : unable to install packages.

Is there a ways to solve this problem? To just maintain one folder for library

3 Answers

Incase of Mac, go to Applications, then right click on RStudio and

  1. Select "Show Package Contents"
  2. Go to Contents/MacOS
  3. Now open terminal(in bash mode). Type sudo and drag the RStudio.exec into terminal and press on ENTER

Now RStudio will have admin access!

For completeness, I think there should be an Ubuntu answer to go along with the Microsoft and Apple answers. (Note:I'm using 18.06, and not 20.x.)

What doesn't work:
On my Ubuntu/Linux system, when Rstudio is installed the call start RStudio from a terminal looks something like the following:

(base) username@sysname:~$ rstudio 

It starts, but has the permissions of the user, and can have access errors.

What gives admin power:
To give it better permissions, you can use sudo.

(base) username@sysname:~$ sudo rstudio 
[sudo] password for username: <enter password here>

It starts in a different user location, but has more power. After it is installed you can run it the regular way and the packages are still installed.

Extra credit:
Here are some (currently) relevant links for RStudio on Ubuntu:

Related