Installing a Package

I am trying to install a package on RStudio (3.6.2). I downloaded Rtools but I'm not sure how to load this in RStudio in order to install the package I need. Any help would be appreciated!

I think you are a little confused, there is no 3.6.2 version of RStudio (that is the R version) and you install packages into R (the programming language) not RStudio (the Integrated Development Environment - IDE, for the R programming language).

Can you tell us what package are you trying to install, which command are you using and what error message do you get?

Right, that makes sense. Should I open R or RStudio when I'm installing packages? I'm trying to install devtools using install.packages("devtools"). This is the message I get:

WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

(then it tries a whole bunch of URLs)

Error in install.packages : cannot open file 'C:/Users/Erika/Documents/R/win-library/3.6/fileffc7d7e2d86/colorspace/CITATION': Permission denied

It doesn't matter just open the one you are going to work with.

About your error message, it seems like you haven't installed Rtools yet and that you don't have write permissions into your user-level library folder, check your user permissions on that folder (you could also try running RStudio as administrator).

I downloaded Rtools35.exe from this site: https://cran.r-project.org/bin/windows/Rtools/

I can find the folder on my computer but it isn't recognized by R.

library(Rtools) returns "there is no package called Rtools"

Rtools is not an R package so no need to load it, you just have to install it in your system like any other windows program.

Ok, you can find it but have you checked your user permission on that folder? Do you have write permissions?

Yes, I have write permission. All of the boxes are checked in my User profile and Admin.

Could you restart your R session (Ctrl+Shift+F10), try to install the package again and post the whole error message you get, as formatted code?

Here is how to post formatted code:

> install.packages("devtools")
Installing package into ‘C:/Users/Erika/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/bin/windows/contrib/3.6/devtools_2.2.1.zip'
Content type 'application/zip' length 342492 bytes (334 KB)
downloaded 334 KB

Error in install.packages : cannot open file 'C:/Users/Erika/Documents/R/win-library/3.6/file4488507d67c1/devtools/DESCRIPTION': Permission denied

What happens if you try to install to the system-level library (running RStudio as administrator)?

install.packages("devtools", lib = "C:\\Program Files\\R\\R-3.6.2\\library")

This function works! I realized that I'm trying to access a file that's not within my User profile, so even with full permissions I can't access this file. I can do everything I need to as Admin but I'll try moving the file so I can use my profile.

Thank you so much for your help!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.