R Package Error(s) - r

I'm running into a bunch of errors when trying to install any packages on R 3.4.4 on Windows 7. Originally, installed.packages() wasn't even working. I had to create the temp directory manually that it was trying to access. I've previously installed/uninstalled R on my machine before, so I'm guessing some of these problems might be stemming from that. I can now view my installed packages.
If I try something as simple as install.packages("tidyverse"), I'll get the following:
Installing package into
‘C:/Users/areynolds/Documents/R/win-library/3.4’
(as ‘lib’ is unspecified)
Error in readRDS(dest) : unknown input format
Attempting update.packages() yields the same error. I've deleted my .Rhistory which saves to my Documents folder. My .libPaths() is the following:
[1] "C:/Users/areynolds/Documents/R/win-library/3.4"
[2] "C:/Program Files/R/R-3.4.4/library"
I'm not really sure what else to try. I've been looking everywhere for the same problem but it's always a little different. I've tried specifying arguments to install.packages like dependencies = TRUE or lib = path. I'd really appreciate any help. Thanks

I was getting the same error.
Closing RStudio completely, then reopening it worked for me.
Note: simply restarting the R Session (e.g. .rs.restartR()) did not work - I am not sure why

Related

How to fix error: package 'tzdb' is not available for this version of R

I'm new at R and trying to usetidyverse. The installation seems to go fine, but when I want to load the package, I get this error: there is no package called 'tzdb'. When I try to install 'tzdb' I get a warning that package 'tzdb' is not available for this version of R. I'm using version 4.0.5, which I believe should work.
Any suggestions on how I can get this package to work (so I can start using tidyverse)?
Edit: I've added an image of the code I ran + the outputs of sessionInfo() , options("repos") and .libPaths() below. (I'm sorry I can't copy paste code nor use the browser of the virtual machine that I work from).
https://i.stack.imgur.com/hra1r.png
It does give a warning stating that the CRAN mirror is set to an insecure URL. Could that be the problem? It didnt't seem matter for the other packages.

I have an error message "The system cannot find the path specified" when installing Caret package in R

When I installed CARET package in R, I got following error message.
Error in install.packages : path[1]="D:\Users\hrdchs\Documents\.Rhistory\R-3.6.0\library": The system cannot find the path specified
I tried to find Document.Rhistory, I could not find the folder ".Rhistory" under Documents folder, I could not find any. When I tried to manually create folder with name of ".Rhistory", system does not allow a folder name starting with ".". I guess this may cause the problem.
Can you please help?
Thanks
In addition to doing install.packages("caret"), I tried following:
It really took a long time but still encountered the same problem.
install.packages("caret",
repos = "http://cran.r-project.org",
dependencies = c("Depends", "Imports", "Suggests"))
setwd("D:/Users/hrdchs/Documents/0 SHR/R/Attrition Analysis/IBM attrition data set")
HRdata <- read.csv("IBMhrData.csv")
library(caret)
By the way, I upgraded R from 3.5.1 to version 3.6.0 trying to help to resolve this issue.
I wonder if this issue is caused by this upgrade.

Issue installing a package in R

I'm new to R. Trying to install the package UsingR but running into problems:
library(UsingR,lib="C:\[whereitwent]")
Loading required package: HistData
Error: package ‘HistData’ could not be loaded
In addition: Warning message: In library(pkg, character.only = TRUE, logical.return = TRUE, lib.loc = lib.loc) : there is no package called ‘HistData’
Now when I did the install.packages("UsingR", lib="C:\[whereitwent]") bit, there was a weird part:
Warning: unable to move temporary installation ‘C:[where it went]\library\file7946ce71334\acepack’ to ‘C:\[whereitwent]\R-Portable\App\R-Portable\library\acepack’ package ‘HistData’ successfully unpacked and MD5 sums checked
I was having this same problem yesterday except instead of "there is no package called 'HistData' it was telling me there is no package called 'Formula'. I uninstalled and reinstalled R Portable this morning, tried again, and this is the result. My professor did this exact thing on her computer right in front of me yesterday and everything worked fine. I've tried this on two computers myself and it's the same issue both places. I've tried googling this but can't find anything substantive, and frankly I'm not really even sure how to google this exact issue. Can anyone help me identify the problem?
Note: "[whereitwent]" is my edit here so I'm not showing off my whole thing including my name. Everything else is copied and pasted exactly as is.
If you just want to be able to install packages, this will set library path:
.libPaths('C:/[path]')
you might need to escape the slashes, I'm sorry I don't use windows. You can add this to a file .Rprofile in your home folder and you won't have to do it again.
Alternatively (or in concert) you may want to look at the packrat package which will install packages with the project you're working on
This error is related to permissions issues, run R or RStudio as administrator (assuming you're on windows) and re-install the package.
If you are unable to run as administrator you usually will not be able to write to the C:\Program Files directory on a corporate computer. All you need to do is change the directory to which the package is installing to a folder to which you have read write permissions. For example, on my computer:
install.packages("gdata", lib = "C:/Users/mkemp6/Desktop/Rscrap", repos = "http://dirichlet.mat.puc.cl/")
To view permissions on a specific folder, right click the folder, select the "Security" tab and and highlight your username.
The same problem was solved by updating R to 3.1.3
I was experiencing similar issue on my Ubuntu machine. I solved it by running R as a "sudo" user and then install the packages from CRAN.

I am unable to use install.packages with the pkgs parameter to install a package from a local file (Win8.1, R3.10)

I am trying to install the rClr package. The instructions for this are to copy the package file onto the local computer and use install.packages(pkgs = "c:/.../rClr_0.5-2.zip"). I have a laptop, a server and a desktop. The laptop and the desktop are Windows 8.1, the server Windows 2012. All run R 3.1.0. The desktop installs rClr without a problem. The other two return the warning (error) message:
package ‘c:/.../rClr_0.5-2.zip’ is not available (for R version 3.1.0).
I've tried all obvious things. The error is pretty generic, it is given whenever install.packages can't find a file. The package is compatible with R 3.1.0, as evidenced by the fact it installs on my desktop. I've check for silly mistakes. I've tried moving the file to simpler directory structures (in case install.packages had a problem with spaces or special characters), I've given it maximum file permissions, tried playing around a few other things, but nothing makes a difference. I also tried replacing the local reference with a reference to the http link, and tried download another random package from CRAN to see if that would install, and both gave the same error message. I can't think of anything different in the environment of the laptop and the desktop. install.packages does work when installing the standard packages from CRAN.
Am I missing something obvious? Is there any known issue with install.packages (I thought maybe security but couldn't find anything on internet)? Are their ways to force an installation? Can anyone recommend something else to try?
Thanks.

Did the subdirectory structure of package repositories change as of R 2.15.2?

Kind of embarrassing / a no-go, but since it hasn't been that long that I've moved from "pure user" to "beginner-developer", I've never actually read the CHANGELOG when a new R version came out - well until today (and I have the feeling I should make this a habbit) ;-)
Yet I'm not sure if the supposed change actually occurred since I couldn't find anything about it at a first glimpse at the CHANGELOG of R R 2.15.2:
Actual question
Is it possible that the (subdirectory) structure of package repositories changed from
./bin/windows/contrib/2.xx/
to
./src/contrib/2.xx/ or even ./src/contrib?
Or at least that the PACKAGES file now needs to live here: ./src/contrib/PACKAGES?
Background info
Up to version 2.15.1, the following path worked to install packages from my local package repository:
path.repos <- "L:/R/packages"
repos <- file.path("file://", path.repos)
Function contrib.url would take repos and expand it to the right subdirectory:
> contrib.url(repos)
[1] "file:///L:/R/packages/bin/windows/contrib/2.15"
But when I try to run install.packages(), I get the following error for R 2.15.2:
> install.packages("mypkg",
+ lib=file.path(R.home(), "library"),
+ repos=repos,
+ type="win.binary"
+ )
Error in read.dcf(file = tmpf) : cannot open the connection
In addition: Warning message:
In read.dcf(file = tmpf) :
cannot open compressed file 'L:/R/packages/src/contrib/PACKAGES', probable reason 'No such file or directory'
>
When I do the same with R 2.15.1, everything works smoothly.
Due dilligence
There are some references with respect to repositories in the CHANGELOG, but the only section I found that gives me some evidence that the supposed change occurred is this:
PACKAGE INSTALLATION
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
Just had a look at the official documentation again and got the idea that maybe arg type is not passed along to contrib.url() correctly as it seems to me install.package() is looking at the place for type="source" packages?
This particular bug isn't the same as mine.
This issue relates to checks install.packages() now runs before installing. As Rappster said, it tries to find a source package to compare the binary version with:
For a Windows or Mac OS X binary package install, install.packages() will check if a source package is available on the same repositories, and report if it is a later version or there is a source package but no binary package available.
So a simple way of squashing this message is creating the R/src/contrib directory and running tools::write_PACKAGES() in that directory to create (an empty) PACKAGES file.
And of course, the reason you aren't getting this message in 2.15.1 is that it doesn't do the checking (see R NEWS quote above) that 2.15.2 performs.
I have submitted a bug report of my issues. No news yet. May post it to the R mailing list as well.

Resources