Failed installation of a Bioconductor package because the library path is not writtable - bioconductor

I am trying to install a bioconductor package (XVector) but it pops an error :
Installation paths not writeable, unable to update packages
path: C:/Program Files/R/R-4.2.2/library
In my library, I have two paths:
.libPaths()
[1] "C:/R" "C:/Program Files/R/R-4.2.2/library"
The 1, I created it on my own, and the second is the one comew when isnstalling R
How can I delete the C/program file one ? I want it to be installed in the first folder
I also checked the variable name (R_LIBS_USER) and value ("C:/R"), and edited them to be for the first directory
Any suggestion ?
I am trying to install a bioconductor package (XVector) but it pops an error :
Installation paths not writeable, unable to update packages
path: C:/Program Files/R/R-4.2.2/library
In my library, I have two paths:
.libPaths()
[1] "C:/R" "C:/Program Files/R/R-4.2.2/library"
The 1, I created it on my own, and the second is the one comew when isnstalling R
How can I delete the C/program file one ? I want it to be installed in the first folder
I also checked the variable name (R_LIBS_USER) and value ("C:/R"), and edited them to be for the first directory
Any suggestion ?

Related

Changeing directory in R studio when installing packages

How do i choose the library which the package is install in in Rstudio?
When i run "install and restart" i get this error:
installing to library 'C:/Program Files/R/R-4.0.0/library'
Error: ERROR: no permission to install to directory 'C:/Program Files/R/R-4.0.0/library'
Exited with status 1.
I want it to install on "h:/r_packages"
As I understand you want to install your personal package. I don't find any option for the library path in RStudio. You can run this code in the console:
withr::with_libpaths("h:/r_packages", devtools::install())
You have to run this command when the current directory is the one of the package. Otherwise use the pkg argument of devtools::install to specify the package directory.
The second argument of install.packages is lib, which specifies the library directory.
The help reads:
lib
character vector giving the library directories
where to install the packages.
Recycled as needed.
If missing, defaults to the first element of .libPaths().
So, the below would work, though I cannot try on my end.
install.packages("package_name", lib="h:/r_packages")

syntax error near unexpected token - R package Install

I am trying to install an R package along with its dependencies. But it is throwing error.
$ install.packages(rvest_0.3.5.tar.gz, dependencies=True)
-bash: syntax error near unexpected token `rvest_0.3.5.tar.gz,'
I am new to R please help me how can I download this along with it dependencies.
Before this, I tried following
$ R CMD INSTALL rvest_0.3.5.tar.gz
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
ERROR: dependencies ‘httr’, ‘magrittr’, ‘selectr’ are not available for package ‘rvest’
But it failed with dependent packages are missing error. And obviously it is cumbersome to install the dependent packages manually. Hence I tried package.install
You need to run it with quotes and capital TRUE:
install.packages("rvest_0.3.5.tar.gz", dependencies = TRUE)
Note this will only work if you have unix-like system and the file is located in your current working directory (check with running getwd() from your R session). Otherwise you need to provide full path to the file (like "~/somefolder/mydata/rvest_0.3.5.tar.gz").
If you run Windows, then you need .zip file instead of .tar.gz.
If you are connected to internet, just run:
install.packages("rvest")

Anaconda R environment can't access libraries/packages when in R project of github repository

I have an R environment in Anaconda with all the packages I need and use. I added a private repository from github onto my pc using the conda CLI. The project files includes an renv folder as well a .Rproj file. When I try to open any of the R scripts in the project without opening the Rproj file to open the project, they all show up as blank, and when I try to open a csv file it says it doesn't exist. When I open the Rproject, I cannot access any of my libraries or packages that I usually have access to in R. When I tried to install a package in this environment, I got the error:
warning in system(paste(cmd, "shlib-clean")) : 'make' not found warning in system(cmd) : 'make' not found error: compilation failed for package 'pkgload' * removing 'c:/users/poona/<repo name>/renv/staging/1/pkgload'
What's going wrong? I just want to access the scripts of the repository and load the packages of my usual environment. Any help is appreciated!

How to install a R package from local folder with the dependencies installation still in same folder? [duplicate]

Suppose I need to install a number of packages on a (Linux) machine that does not have an internet connection. Let's say that I downloaded a copy of cran and burned it on a DVD that I bring to the offline location:
wget ftp://cran.r-project.org/pub/R/src/contrib/*.tar.gz
I can even add a PACKAGES file that contains an overview of all the source packages and their dependencies:
library(tools)
write_PACKAGES()
How could I use this offline to install a source package in such a way that dependencies are resolved and installed from the local files as well? For example, someone wants to install package ggplot2, which has a fairly deep dependency structure. Assume the source package of ggplot2 and all of its dependencies are available as source packages in the current working directory. If I do:
install.packages("ggplot2_0.9.1.tar.gz", repos=NULL)
This results in an error, because the dependencies are not resolved at all. Alternatively:
install.packages(list.files(pattern="*.tar.gz"), repos=NULL)
However this also ignores the dependency structure, and tries to install packages in alphabetical order, which will also fail.
I looked into available.packages and contrib.url but I just can't find an example of installing a source package from a local file including it's dependencies.
The correct answer was given by Joshua Ulrich in the comment on the question:
The key is prefixing the argument to either repos or contriburl with file://. So in Unixy systems one could do:
install.packages("ggplot2", contriburl="file:///path/to/packages/")
This assumes that all required source packages, as well as a PACKAGES index file is available in /path/to/packages. If no PACKAGES file is present, this should be generated first using:
library(tools)
write_PACKAGES("/path/to/packages/")
which will generate an index of all source packages found in this directory. Note that in the example, there are 3 slashes behind the file: prefix. The third slash indicates a path relative to the root of the file system.
The difference between the repos and contriburl argument is that repos will append another /src/contrib to the path specified, as this is usually where source packages are located on an official CRAN repository mirror.
With reference to Answer above, if installation is in Windows, then write_PACKAGES() generates two files: PACKAGES and PACKAGES.gz under '/path/to/packages/' directory where all zip files are placed. The file PACKAGES.gz should be deleted before install.packages() function is correctly able to read the lone PACKAGES file else 'cannot open compressed file' error appears.
I had the same issues during offline installation. Somehow it didn't work by command line.
I downloaded, extracted all the dependencies (Keeping check of the min version required) and pasted the folders in the library folder. This way only my problem got solved.

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
It is the first time I see it and I cannot solve it. Can anyone help me ?
This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.
Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.
Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.
Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:
https://cran.r-project.org/src/contrib/Archive/
If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:
https://cran-archive.r-project.org/bin/windows/contrib
This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:
https://cran.r-project.org/bin/windows/contrib
Once the zip file is downloaded, you can run the following R code line to install the package:
# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Resources