I'm having trouble installing packages

install.packages("tidyverse")

output:
install.packages("tidyverse", lib="C:/Program Files/R/R-3.6.1/library")
also installing the dependency ‘rlang’

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/rlang_0.4.1.zip'
Content type 'application/zip' length 1104621 bytes (1.1 MB)
downloaded 1.1 MB

trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/tidyverse_1.2.1.zip'
Content type 'application/zip' length 93068 bytes (90 KB)
downloaded 90 KB

package ‘rlang’ successfully unpacked and MD5 sums checked
package ‘tidyverse’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
C:\Users\sibac\AppData\Local\Temp\RtmpGA8Ozp\downloaded_packages

#> when I call library function on tidyverse I get this output 
library(tidyverse)

output:

library(tidyverse)
Error in library(tidyverse) :
‘tidyverse’ is not a valid installed package

Seems like less output than expected from package installation

I would expect a lot more output than what's being shown on successful or unsuccessful installation. Downloading and unpacking doesn't indicate that the package was installed successfully. It only indicates that the package was retrieved successfully.

The tail end of a dplyr install for me reports:

** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (dplyr)

Try installing Rtools

Running on windows, you may need to install Rtools in order to build some packages from source.

I have fixed the issue! I just recently udated R and Rstudio, and for some reason they both did not have administrator privileges on my computer. Next, I used the code below to switch the installation file path.

myPaths <- .libPaths()   #> get the paths
myPaths <- c(myPaths[2], myPaths[1])  #> switch them
.libPaths(myPaths)  # reassign them

I still don't understand why when I install a pachage it downloads the zip files to this file location:
C:\Users\sibac\AppData\Local\Temp\RtmpuE5xVt\downloaded_packages
and unziped files to my defalut file location: C:\Program Files\R\R-3.6.1\library

1 Like

Packages when being installed are put in a temp location where all the building/checking/verification is done. When that succeeds, the package files are copied over to the library location. If the package install fails, the temp directory and contents are deleted.

It means the only packages that appear in the library were successfully installed.

You can specify a location to keep the R packages you install and use in a user directory, so you won't need admin privileges. I do this and a few other things I just like having all the time in my .Rprofile file. Here's a brief write up about using .Rprofile if you're curious.

options(
  repos = c(CRAN = "https://cran.rstudio.com/"),
  browserNLdisabled = TRUE,
  deparse.max.lines = 2)

# Set lib path
.libPaths( "~/R/x86_64-pc-linux-gnu-library/dev/" )

if (interactive()) {
  suppressMessages(require(devtools))
}
2 Likes

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