Cant install a package in R
There are a couple of potential solutions at this link: Windows 7, update.packages problem: "unable to move temporary installation"?
Could be an antivirus problem, or possibly lacking administrator privileges. The link recommends installing R in a different folder, or downloading the zip file for the package and installing it by hand.
Windows 7, update.packages problem: unable to move temporary installation ?
I found that the problem indeed is the antivirus "real time file system protection". I do the following to fix the problem:
trace(utils:::unpackPkgZip, edit=TRUE)
I edit line 140 (line 142 in R 3.4.4):
Sys.sleep(0.5)
to:
Sys.sleep(2)
I seems like the antivirus stalls the creation of the package tmp dir. After changing it to 2 seconds the error is gone.
EDIT: to do this programmatically execute
trace(utils:::unpackPkgZip, quote(Sys.sleep(2)), at = which(grepl("Sys.sleep", body(utils:::unpackPkgZip), fixed = TRUE)))
(credits @DavidArenburg)
Related Topics
Convert Accented Characters into Ascii Character
Sum of Two Columns of Data Frame with Na Values
In Read.Table(): Incomplete Final Line Found by Readtableheader
Avoid Scientific Notation in Cut Function in R
Overlay Grid Rather Than Draw on Top of It
Two Y-Axes with Different Scales for Two Datasets in Ggplot2
R: Updating a Data Frame with Another Data Frame
Finding Euclidean Distance in R{Spatstat} Between Points, Confined by an Irregular Polygon Window
Move Nas to the End of Each Column in a Data Frame
Annotate Values Above Bars (Ggplot Faceted)
Get the Size of the Window in Shiny
Knit One Markdown File to Two Output Files
How to Have Na's Displayed First Using Arrange()
Using R to Download Zipped Data File, Extract, and Import .Csv
How to Use Ggplot2's Geom_Dotplot() with Both Fill and Group
Error in File(File, "Rt"):Invalid 'Description' Argument in Complete.Cases Program