Installing Packages Onto R

Install R packages through Jobs tab in Rstudio

There's an R package {job} which can be used to run any r code directly from a script or console. To install a package as a Rstudio job:

# install.packages("job")

job::job({
install.packages("pkg_name")
})

Also {job} provides Rstudio Addins to easily run selected code as a job.
see here for more examples.

Why does R show a package error immediately when I open the program?

Based on responses in the comments, I'll promote my comment to an answer.

Two possible causes of this problem are

  • you have a .Rprofile file in your home directory that is trying to load packages
  • you have a .RData file in your current working directory that is being auto-loaded; it has an object in it that will trigger the loading of this package

Note that in either case files whose names start with a . are usually invisible by default in file managers/file listings, so you may have to search for them carefully

file.exists(".RData") and file.exists("~/.Rprofile") will tell you whether these files exist; you could diagnose the problem by moving/renaming each one temporarily.

Installing an R package from local unzipped folder

If it is an unzipped Windows binary (e.g., from CRAN), you can just copy and paste the entire package directory into your library folder. You could also, presumably, use file.copy() to do so if you wanted to do it within R. install.packages() is failing (weirdly) because you're giving it something other than the typical package source or zipped binary that it is expecting.



Related Topics



Leave a reply



Submit