Error installing packages in Rstudio - r

I have R 3.2.2 setup installed in my system,with RStudio version 0.99.489. When I tried to install rJava package,
install.packages("rJava")
I am getting following Error:
Warning in install.packages :
downloaded length 4878 != reported length 200
Error in install.packages : subscript out of bounds
But if I run the below command before installing any package,it works fine, but I don't want to do this every time I install a package.
options(repos=structure(c(CRAN="http://cran.us.r-project.org")))

You can stick the line you want executed at every startup in your .Rprofile file which should be in your home directory. I have 3.2.3 version of R and that worked; however I do get a warning message about using a non-http version of the site.
Similarly to you, I was finding the original repository the system was using was failing to install the packages--not finding the package or downloading a file with too few bytes, perhaps because of a transient problem. You might want to consider not putting this in your .Rprofile file or commenting the line outin case this is a temporary workaround.

Related

RStudio - Not able to install packages after reinstallation of R & constant working directory issues

I recently had to have a new laptop build at work and therefore reinstalled R and R Studio through a designated 'Company Portal' that did the software installation for me (this might be the problem). When now trying to install and load packages for use, I am running in to the below error for packages (in this case for tidyverse):
Warning message: In options(stringsAsFactors = TRUE) :
'options(stringsAsFactors = TRUE)' is deprecated and will be
disabled Error in setwd("C:/R/WorkingDir") : cannot change working
directory Execution halted Warning in install.packages :
installation of package ‘tidyselect’ had non-zero exit status
I also had this error when I first loaded R up that seems to be reappearing due any attempt to install packages:
Error in setwd("C:/R/WorkingDir") :
cannot change working directory
I've never had this issue before using RStudio across numerous machines and software versions, can anyone advise what is going on? My name (and thus C:\ user file path(s)) does have an apostrophe in it, if that matters - but it has never been an issue before. Is some key installation setting now misaligned and if yes, can anyone advise how to resolve?

Unable to install quantreg package and update R version

I am using R version 3.3.1 on RStudio interface, and a Windows 10 OS. I was trying to install the 'quantreg' package for quantile regression, however I was getting the error message
Warning in install.packages :
InternetOpenUrl failed: 'The operation timed out'
Warning in install.packages :
downloaded length 180224 != reported length 1521162
Warning in install.packages :
package ‘quantreg’ is not available (for R version 3.3.1)
I repeated the process afterwards several times but got the last line of the above error all the time. Thinking it was due to using an older R version, I tried updating by installing the 'installr' package, but that too gave me the same error as above. I tried updating R from the Tools Menu, but it kept telling me that the current R version is the latest.
Also this is my first time here, so apologies if I've messed up the blockquoting.
You need to downgrade R.
Download an older version here (I recommend 3.2.5) and install.
Then (in R), go to Tools > Global Options > press the "Change" button.
Now simply select the version you want and restart R and try reinstalling the package.

Zipping a file using R

Im trying to zip a file in R that is in a folder on my PC
My code is below
setwd('C:/temp')
zip(zipfile = 'testZip', files = 'test.txt')
Im getting the error
Warning message: running command '"zip" -r9X "testZip" "test.txt" '
had status 127
I found on this site an answer that involves messing with the windows envoirnment: Create zip file: error running command " " had status 127
However when i try to install Rtools i get the error
Warning in install.packages : package ‘rtools’ is not available (for
R version 3.2.0)
I am restricted to being able to zip the file as either 7zip or .zip
The version of R i have is: R version 3.2.3 (2015-12-10)
Can anyone help?
Note: This is more of a comment, but I don't have enough rep to do that.
Did you type in install.packages("rtools")? I ask because your warning says rtools. If that is the case try install.packages("Rtools"). Not capitalizing the R makes a difference in R.
Unfortunately I'm not at my computer so I can't test this. If this doesn't work let me know and I'll update my answer.
EDIT: After some more research it looks like install.packages() doesn't work for Rtools. You have to manually download it from online. Here's a link to an Rtools wiki on github that tells you how to download Rtools: https://github.com/stan-dev/rstan/wiki/Install-Rtools-for-Windows

ggplot2 version 1.0.1 won't load into R 3.2.2 for Windows

I just started using R and downloaded ggplot2
install.packages("ggplot2")
I get the following warning:
Warning in install.packages:
unable to move temporary installation '\\CHI-FIlE-01\UserFolders$\naresh.kavuri\Documents\R\win-library\3.2\file27ac2d3b613c\ggplot' to '\\CHI-FILE-01\UserFolders$\naresh.kavuri\Documents\R\win-library\3.2\ggplot2'
This warning is followed up with this error:
Error: invalid version specification 'NA'
In addition: warning message:
In utils:::packageDescription(packageName, fields = "Version") :
no package 'knitr' was found
As anyone come across this problem before? Did I do something wrong in the setup?
If you have multiple versions of R running, and you try to update or reinstall a package in one version of R while it is loaded in another, then the old version of the package doesn't get completely removed.
Try closing down all instances of R, manually deleting the folder containing the package, then opening a single version of R and reinstalling.
As Pascal commented, antivirus file scans can also interfere with the installation process. Sometimes downloading the package zip/tar.gz file then installing from disk can circumvent the issue.

Error when installing R package using Rstudio

I want to install http://cran.r-project.org/src/contrib/Archive/mecdf/ using RStudio but when I use
> install.packages('C:\\Users\\jandre\\Desktop\\mecdf_0.6.1.tar.gz', repos=NULL, type="source")
I get this error:
Installing package into ‘C:/Users/jandre/Documents/R/win-library/3.1’
(as ‘lib’ is unspecified)
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Warning in install.packages :
running command '"C:/Program Files/R/R-3.1.1/bin/x64/R" CMD INSTALL -l "C:\Users\jandre\Documents\R\win-library\3.1" "C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘C:/Users/jandre/Desktop/mecdf_0.6.1.tar.gz’ had non-zero exit status
This occurs in every package I want to install using the tar.gz file. I'm on Win7 x64. RStudio Version 0.98.1028
Can't think of a way to fix this at the moment -- sorry -- but the R administration manual says explicitly:
Note that installing R into a directory whose path contains spaces is not supported, and at least some aspects (such as installing source packages) will not work.
I don't know why this doesn't bite people much more often, given that C:/Program Files/... seems like a relatively normal place to install things on Windows.
I would also expect that the double quotation marks around your R executable name ("C:/Program Files/R/R-3.1.1/bin/x64/R") in the system call should have protected you from this problem ... ?
I had the same error message with the installation of some packages(under Windows 10 OS with R and Rstudio).
It seems that the R software (not R Studio) is dealing with the library where package are installed.
I uninstalled R and Rstudio and installed it a path without space (ex: C:\Program\R).I tried to load the packages that previously failed and it seemed to fix the problem.

Resources