Unable to install package on RStudio

greeting,
i'm new to R and Rstudio, already install them to my computer but I'm not able to install the package.

my code


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

RTools: Toolchains for building R and R packages from source on Windows
Warning in install.packages :
'lib = "C:/Program Files/R/R-4.1.3/library"' is not writable
Warning in install.packages :
cannot create dir 'C:\Users\hi\OneDrive?????????', reason 'Invalid argument'
Error in install.packages : unable to create ‘C:/Users/hi/OneDrive/?????????/R/win-library/4.1’
Warning message:
In normalizePath(path.expand(path), winslash, mustWork) :
path[1]="C:/Users/hi/OneDrive/?????????": The filename, directory name, or volume label syntax is incorrect

after installing Rtools also get the same message

You need to run RStudio as "Administrator" to be able to install into this folder.

R has problems with cloud-synced folders (OneDrive in your case) and non-ASCII characters in folder paths, If you opt for using a user level package library, I recommend you to set your package library in a non-synced folder that doesn't include non-ASCII characters on its path.

You can change the default library folder by setting your R_LIBS_SITE environmental variable in a .Reviron or .Rprofile file. For example:

# In a .Renviron file you can set it by adding a line like this one with the desired location 
R_LIBS_SITE="C:\\Program Files\\R\\R-4.1.2\\library"

For a more detailed explanation, you can read this blog post

1 Like

thanks andresrcs, i run RStudio as "Administrator" and it works

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.