Unable to Install R packages in Visual Studio Code - r

I wanted to use R in visual studio code and so I tried running some basic codes and it worked. But whenever I try to install any package (eg. ggplot2) from the R-Extension in the VsCode I get this error
Installing package into 'C:/Users/krish/Documents/R/win-library/4.1'
(as 'lib' is unspecified) Warning in install.packages(c("ggplot2"),
repos = "https://cran.r-project.org/") : 'lib =
"C:/Users/krish/Documents/R/win-library/4.1"' is not writable Error in
install.packages(c("ggplot2"), repos = "https://cran.r-project.org/")
: unable to install packages Execution halted The terminal process
"C:\Program Files\R\R-4.1.2\bin\R.exe '--silent', '--slave', '-e',
'install.packages(c('ggplot2'),repos='https://cran.r-project.org/')'"
terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
I have added r-library and r bin to env path following some other posts but it is not working.

Related

Can`t install datasets in R, not cvs and not xlsx

I am new to RStudio. And it was working well, about a week ago my computer update the new version of the system. And from this moment R doesnt work like before. I am trying to load at datasets in .xlsx and .cvs - it doesn`t work. R write like this:
** Installing R Package Dependencies for Excel Import: `'readxl', 'Rcpp'`
[1/5] Installing cellranger...
�������������� � utils::install.packages("cellranger", repos = "https://cran.rstudio.com/") :
'lib = "C:/Program Files/R/R-4.0.2/library"' is not writable
������ � utils::install.packages("cellranger", repos = "https://cran.rstudio.com/") :
unable to install packages
������: sourceWithProgress -> eval -> eval -> <Anonymous>
���������� �����������
I trying to install xlsx packages, it writes like this:
`install.packages("xlsx")`
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Warning in install.packages :
'lib = "C:/Program Files/R/R-4.0.2/library"' is not writable
Warning in install.packages :
не могу создать каталог 'C:\Users\Lina\OneDrive\?????????' по причине 'Invalid argument'
Error in install.packages : unable to create ‘C:/Users/Lina/OneDrive/?????????/R/win-library/4.0’
if somebody can help me?
Since you appear to be a Windows user, I can offer two pieces of advice.
First, make sure your R installation is in a location that you have write permissions to. In some Windows OS, the Program Files locations are by default locked down. If the computer is yours, you should be able to change the permissions to the R folder. How to do so will vary a little by your windows version, so I will not provide more instructions. One other thing you can try is to set R and RStudio to "Run as administrator".
Second, OneDrive is a bad place to put your R installation or your R packages. OneDrive does not support all filenames and file extensions. R and its packages will generate a number of unsupported files, and you will continually be notified that something will not sync and that you should do something about it.
On a Windows machine, I generally install R and set up the library at C:\R where I have appropriate permissions.

In R (and when installing ROracle package), how do I set OCI_LIB64?

In R (and when installing ROracle package), how do I set OCI_LIB64? I've downloaded Oracle Instant Client and have pointed the wd and the OCI_LIB64 to that. I have Windows 10 Enterprise. It's RStudio version 1.1.463 and R version 3.4.3.
I tried the following:
setwd('C:\\Users\\sriley03\\Documents\\') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
set OCI_LIB64=C:\Users\sriley03\Documents\instantclient_19_3
install.packages('ROracle_1.3-1.tar.gz', repos = NULL)
but I get the following output and errors:
> setwd('C:\\Users\\sriley03\\Documents\\') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
The working directory was changed to C:/Users/sriley03/Documents/ inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.Error: unexpected symbol in "set OCI_LIB64"
> setwd('C:\\Users\\sriley03\\Documents\\instantclient_19_3') # set to path of download (remember to escape slashes ie: c:\\users\\etc..)
The working directory was changed to C:/Users/sriley03/Documents/instantclient_19_3 inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.> set OCI_LIB64=C:\Users\sriley03\Documents\instantclient_19_3
Error: unexpected symbol in "set OCI_LIB64"
> install.packages('ROracle_1.3-1.tar.gz', repos = NULL)
Warning: invalid package 'ROracle_1.3-1.tar.gz'
Error: ERROR: no packages specified
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.3\library" "ROracle_1.3-1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘ROracle_1.3-1.tar.gz’ had non-zero exit status
What can I do so that I can set OCI_LIB64 properly so that I can install ROracle?
Thanks!
UPDATE (8_28_19):
I've set the OCI_LIB64 and the OCI_INC to the correct paths
Sys.setenv(OCI_LIB64="C:\\Users\\sriley03\\Documents\\oreclient_install_dir\\instantclient_19_3")
Sys.setenv(OCI_INC="C:\\Users\\sriley03\\Documents\\oreclient_install_dir\\instantclient_19_3")
But now I get the following response (even though all the required headers are in that file):
* installing *source* package 'ROracle' ...
** package 'ROracle' successfully unpacked and MD5 sums checked
Oracle Client Shared Library 64-bit - 19.3.0.0.0 Operating in Instant Client mode.
found Oracle Client C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3
found Oracle Client include C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3
ERROR: cannot find Oracle Client include headers in C:\Users\sriley03\Documents\oreclient_install_dir\instantclient_19_3.
Please set OCI_INC to correct location.
Warning: running command 'sh ./configure.win' had status 1
ERROR: configuration failed for package 'ROracle'
* removing 'C:/Program Files/R/R-3.4.3/library/ROracle'
In R CMD INSTALL
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-34~1.3/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.4.3\library" C:\Users\sriley03\AppData\Local\Temp\RtmpWUfabz/downloaded_packages/ROracle_1.3-1.tar.gz' had status 1
Try to download the SDK Package from Oracle and unzip it in your instant client folder.
set the environment variable OCI_INC to the 'include' folder located in your instant client folder: ..."instantclient_xx_x\sdk\include"
Then, reinstall the packages.
If you still get a failure error, try to copy all files from sdk\include folder to your R include folder, then try again

Why can I not use the function read.affybatch() in biocLite("affy") using RStudio?

I have some Affymetrix data that I would like to open using the read.affybatch() command in affy. I have downloaded the biocLite and affy packages with no issues, but as soon as I try and read my .CEL files using the read command it comes up with the following problem:
Library - package hgu133acdf not installed
Library - package hgu133acdf not installed
In addition: Warning messages:
1: In read.affybatch(filenames = "MonoHypo_U133A_04_12_03.CEL", "MonoC_U133A_04_12_03.CEL", :
Incompatible phenoData object. Created a new one.
2: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.2\library" C:\windows\TEMP\RtmpKKBTXV/downloaded_packages/hgu133acdf_2.18.0.tar.gz' had status 1
3: In install.packages(cdfname, lib = lib, repos = biocinstallRepos(), :
installation of package ‘hgu133acdf’ had non-zero exit status
4: missing cdf environment! in show(AffyBatch)
5: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.2\library" C:\windows\TEMP\RtmpKKBTXV/downloaded_packages/hgu133acdf_2.18.0.tar.gz' had status 1
6: In install.packages(cdfname, lib = lib, repos = biocinstallRepos(), :
installation of package ‘hgu133acdf’ had non-zero exit status
So, the issue seems to be this hgu133acdf package, but using the command from BioConductor to install this package I get the following error:
biocLite("hgu133acdf")
BioC_mirror: https://bioconductor.org
Using Bioconductor 3.4 (BiocInstaller 1.24.0), R 3.3.2 (2016-10-31).
Installing package(s) ‘hgu133acdf’
installing the source package ‘hgu133acdf’
trying URL 'https://bioconductor.org/packages/3.4/data/annotation/src/contrib/hgu133acdf_2.18.0.tar.gz'
Content type 'application/x-gzip' length 1732200 bytes (1.7 MB)
downloaded 1.7 MB
'\\filestore.soton.ac.uk\users\rl1e15\mydocuments\PhD\PhD Year 1 2016-2017\Analysis\In Silico\R\Hypoxia and Normoxia Monocytes'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
ERROR: unable to create 'C:/Program Files/R/R-3.3.2/library/hgu133acdf'
The downloaded source packages are in
‘C:\Windows\Temp\RtmpKKBTXV\downloaded_packages’
Warning messages:
1: running command '"C:/PROGRA~1/R/R-33~1.2/bin/x64/R" CMD INSTALL -l "C:\Program Files\R\R-3.3.2\library" C:\windows\TEMP\RtmpKKBTXV/downloaded_packages/hgu133acdf_2.18.0.tar.gz' had status 1
2: In install.packages(pkgs = doing, lib = lib, ...) :
installation of package ‘hgu133acdf’ had non-zero exit status
I have tried installing hgu133acdf to my local drive using biocLite("hgu133acdf", lib="C:/Program Files/R/R-3.3.2/library") but the same non-zero exit status comes up. Sometimes it tells me I need to update nlme so I try that but the nlme_3.1-130 is not compatible with R-3-3-2 or when I update the package it still doesn't work.
So if anybody was curious, after hours of playing around with R I finally found the solution. As I have a work laptop, administrative rights are not automatically permitted, so I set the security of the directory all my packages download to to allow everything. I ran R as an administrator, installed all the necessary packages that kept flagging up when I tried the read.affybatch() command, and it worked!

Installing package in R Console in IBM Bluemix

I am not able to install packages in R console in dashDB from IBM Bluemix. I am executing the below line:
install.packages('tm')
I am getting this error:
Installing package into ‘/usr/lib64/R/library’ (as ‘lib’ is unspecified)
Warning in install.packages("tm") :
'lib = "/usr/lib64/R/library"' is not writable
Error in install.packages("tm") : unable to install packages
Execution halted
mv: cannot stat `/mnt/blumeta0/home/<userID>//<...>/<...>/output/*': No such file or directory
I have also tried giving the library parameters like this:
install.packages('tm', lib='/mnt/blumeta0/home/<userID>/R/x86_64-redhat-linux-gnu-library/3.2/lib')
I get this error:
Warning in install.packages("tm", lib = "/mnt/blumeta0/home/<userID>/R/x86_64-redhat-linux-gnu-library/3.2/lib/"):
'lib = "/mnt/blumeta0/home/<userID>/R/x86_64-redhat-linux-gnu-library/3.2/lib/"' is not writable.
Execution halted
mv: cannot stat `/mnt/blumeta0/home/dash107933//.3hwv1S2IEeq813rI935Gurz/1467874427867/output/*': No such file or directory
What could be the issue here? Do I have to do any other configuration changes before I try to install the packages? I have also tried to use .libPaths() function to set the library to above mentioned path.
The packages are getting installed properly in RStudio interface though.
Could you please help? Thanks!
PS: The keyinfo and UserIDs are removed in above statements.
I have installed packages using the 'Install Packages' menu item from the Tools Menu. Did you try that ?
See this picture for the menu location. Bluemix R Studio Web Interface

Installing the package ZIGP from R archive

I'm unable to install the ZIGP package in R (version 2.14.1). I've downloaded the file ZIGP_3.8.tar.gz from http://cran.r-project.org/src/contrib/Archive/ZIGP/ to the directory
"C:\Program Files\R\R-2.14.1\library". I've already tried several ways to install this package, but without success! For instance, I entered into the R program as an administrator (item "Run as administrator") and I've tried the command
install.packages("ZIGP", pkgs="C:/Program Files/R/R-2.14.1/library/ZIGP_3.8.tar.gz",repos=NULL), and the error message was:
Warning in install.packages("ZIGP", pkgs = "C:/Program Files/R/R-2.14.1/library/ZIGP_3.8.tar.gz", :
'lib = "ZIGP"' is not writable
Error in install.packages("ZIGP", pkgs = "C:/Program Files/R/R-2.14.1/library/ZIGP_3.8.tar.gz", :
unable to install packages
I've changed the security status in R properties, but the error remains the same.
Do anyone have any idea to solve this problem?
Thanks very much in advance.

Resources