So, apparently the antivirus software on my work computer (which I have no control over) is equipped with “real time file system protection.” I don’t really know what that is, but I know that it often prevents me from installing R packages on my machine, which in turn makes it very difficult to get my analysis done. I don’t know how many people have the same problem, but I’m posting it here for my reference.
First of all, I’ve become accustomed to installing packages through R directly, rather than through R Studio, making sure I get the dependencies:
install.packages("packagename", dependencies = TRUE)
So, the problem with the antivirus is that it will block R from moving the package out of the temporary folder. The antivirus doesn’t like the speed at which it is accomplished apparently. The workaround is to edit the package installer:
trace(utils:::unpackPkgZip, edit = TRUE)
In the window that pops up, I change Sys.sleep(0.5) to Sys.sleep(2). It seems to work great if you slow down the installation process. I don’t know why.