3

R keeps on downloading R packages to microsoft onedrive. How can I disable this and choose where R packages get downloaded?

neilfws
  • 32,751
  • 5
  • 50
  • 63
Noah_Seagull
  • 337
  • 5
  • 18
  • specify the `lib` to where you want to install in `install.packages` or change the `.Rprofile` by specifying the locations in the new order so that by default, it goes to the first path or change the `.libPaths()` by assigning new paths concatenated to the old one in the order you want – akrun Jun 05 '19 at 21:40
  • 1
    Possible dups - https://stackoverflow.com/questions/2698269/how-do-you-change-library-location-in-r or https://stackoverflow.com/questions/31707941/how-do-i-change-the-default-library-path-for-r-packages – thelatemail Jun 05 '19 at 21:58
  • 1
    How can I change the .Rprofile? Everytime I attempt to change the path to .rprofile the file still ends in my onedrive folder – Noah_Seagull Jun 05 '19 at 22:03
  • 1
    @Noah_Seagull - there's more detail in the linked questions - https://stackoverflow.com/a/42643674/496803 - for instance which outlines exactly which line to change in what file. – thelatemail Jun 05 '19 at 22:06
  • For me the problem was that I couldn't find any .Rprofile or .Renviron files on my computer even after changing File Explorer settings to show hidden files. The solution was to use the `versions` package to install an older version of the `usethis` package and then use `usethis::edit_r_environ()` to edit the .Renviron file by adding the following line: `R_LIBS_USER = "C:/target/directory"`, where the target directory is wherever you want to map `.libPaths()` to instead of OneDrive. – coip Mar 11 '21 at 17:35
  • Thank you for the advice. I ended up going with specifying `lib` for determining where packages get installed. I also learned that my institution provides unlimited storage for Onedrive, which is nice because I find myself installing many R packages. – Noah_Seagull Mar 12 '21 at 21:55
  • Glad to hear. I'll just add one more note in case it helps someone with this same problem who uses multiple different versions of R, which normally store packages in different subfolders. In this case, modifying the .Renviron will direct all versions to the same folder, which creates compatibility problems. The workaround is to create multiple subfolders for each version (e.g. `"C:/target/directory/3.5"` and `C:/target/directory/4.0"` and then use `%v` like this: `R_LIBS_USER = C:/R/Library/%v`. That way, whichever version of R you open will load up packages from the appropriate subfolder. – coip Mar 15 '21 at 23:15

0 Answers0