problems with installing r packages on windows 10 - r

I'm having problems installing r packages using R3.4.1 on windows 10.
E.g. I get the following message when trying to install a package:
package ‘ctv’ successfully unpacked and MD5 sums checked
Warning in install.packages :
unable to move temporary installation ‘C:\Program Files\R\R-3.4.1\library\file34470c9f23\ctv’ to ‘C:\Program Files\R\R-3.4.1\library\ctv’
I would really appreciate any assistance to resolve this issue.

Normally one puts the library in C:\user\yourname\Documents\R\win-library. Each version of R will have its library in a separate folder within that folder. In that case you won't get this error. If you reinstall R and accept the default for the library location then it will put the library there and you won't get this error.
If you prefer the configuration you have now because, for example, there are multiple users on your PC that need to share the library, then you will need to be Administrator each time you install a package; however, note that your current configuration is less secure than the default.

Related

Having issues installing an R package from Github

Please be patient with me as I'm a total noob, but I'm really trying to learn.
I'm trying to make a choropleth map for my country, and found an R package on Github that handles it excellently. However, I'm working on a university computer and I don't have write privileges on any drive but M://, so whenever the package tries to install on C:// it obviously throws an error. This hasn't been a problem since I can just specify a libpath as an argument on install.packages, but devtools::install_github does not seem to have such an argument.
I tried using
with_libpaths(new = "M:\R\win-library\3.2", install_github('diegovalle/mxmaps'))
But I got an error message saying
with_libpaths' is deprecated. Use 'withr::with_libpaths' instead.
I take this to mean that I need to install the "withr" package in order to use that? However, I keep getting errors when trying to install that package. First, I got
Warning in install.packages : installation of package ‘withr’ had
non-zero exit status
because of the not having access to C:// issue. I usually bypass this by installing directly from the binaries, but when I try that it tells me
"Warning in install.packages : package ‘withr’ is not available (for R
version 3.2.2)".
Other than updating my version of R (which will be a nighmare since I don't have installation privileges on this machine), how else can I either install withr or find another way to specify the directory to install the package from github?
I would suggest you to go with latest version of 3.4.All above mentioned packages are available under latest version.
Two ways to set local library paths (at least on Linux running R 3.5.3):
(1) At the beginning of your script, set the the .libPaths option to your local library path, i.e.: .libPaths("M:\R\win-library\3.2")
(2) Add to your .Renviron file a line that specifies your local library path: i.e.: R_LIBS="M:\R\win-library\3.2"
Note: For (1) You will need to manually run every time you start a new R session, whereas (2) will be set automatically when R starts.

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.

How do you import an R module to a computer with no internet?

I'm working on a mac computer that has restricted-use data and cannot be connected to the internet. I need an R-module on the computer called rgexf. When I try to install it on R following the instructions here:
> install.packages('[where the zip file is]/rgexf_0.12.03.tar.gz', repos = NULL)
I get this error:
Installing package(s) into '/Users/samfinegold/Library/R/2.15/library' (as 'lib' is unspecified)
Warning: unable to access index for repository NULL/bin/macosx/leopard/contrib/2.15
Warning message: package '/Users/samfinegold/Desktop/rgexf_0.13.01.tar.gz' is not available (for R version 2.15.3)
I don't understand why the package wouldn't be available for the most recent version of R though.
You have specified a source package (identified by the "tar.gz" extension) but not told install.packages to use type ="source". You are also asking for the most recent version of the file which might be mated to version 3.0.0 for R.Its DESCRIPTION file says it does require compilation so you either need properly set-up tools for building source packages (if you want to install from source), or you need an appropriate binary version of the package. Whether there is an earlier version that can be mated to R 2.15.3 is an open question.
If you want to compile packages from source, you must have the correct XCode for the version of OSX that is on your machine. And you may need to get additional development tools from the ATT.research website. And if you have a more recent version of Xcode (higher than 3.x I think), don't forget to install the Command Line Tools package either from the Apple Developer Store or using the drop-down menu in a running installation of Xcode.
There is a MacOS binary at CRAN. Given your difficulties with source installation I would try to get a copy of that on a USB stick and retry with a binary distribution. (You do not need to use type="mac.binary" since that is the default for that parameter to install.packages.
Have you checked the permissions on the computer? The first warning message looks like it could be a root/admin vs. user issue for accessing the file. The other possibility since you have a NULL in the warning message is that you've entered the directory wrong (try without the '/' to lead perhaps).

Unloading and removing a loaded package withouth restarting R

Actual question
Can I unload and remove a package without having to restart an R process that has already required/loaded the package?
I've had a look at this question/answer, but it only deals with part of the problem (unloading)
Background
The reason I want to do this is that I am working on a project-based framework for package development in which I'm also using project-based package libraries in order to keep the standard library "clean" and allow for systematic testing of package dependencies.
The only problem with this is that it's really hard for the user to remember the path to a project-based package library before initializing the project (which also loads all specified package dependencies via require() and makes the project-based library the first one in .libPaths())
Practically, this means that a user currently can't really uninstall a package dependency from the project-based package library in a comfortable way (after initializing the project, that is) and I'm looking for ways to change this.
What I tried
install.packages("forecast")
require("forecast")
detach("package:forecast", unload=TRUE)
remove.packages("forecast")
> install.packages("forecast")
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.15
trying URL 'http://cran.rstudio.com/bin/windows/contrib/2.15/forecast_4.03.zip'
Content type 'application/zip' length 1124001 bytes (1.1 Mb)
opened URL
downloaded 1.1 Mb
package 'forecast' successfully unpacked and MD5 sums checked
Warning: cannot remove prior installation of package 'forecast'
The downloaded binary packages are in
C:\Users\wwa418\AppData\Local\Temp\RtmpYPry89\downloaded_packages
The problem seems to be /forecast/libs/i386/forecast.dll which probably gets registered upon loading and seems to be a tough one to kill ;-)
Any ideas?

Unable to install and run a package in R (windows)

I am working on a 64 bit windows system. And I have a 64 bit, 2.15.1 version of R installed in it. I am trying to install a package called "MethLAB" from the package menu, by selecting its local zip file from the "Packages" menu. However I am running into an error show below.
> utils: : :menuInstallLocal ()
package 'MethLAB' successfully unpacked and MDS sums checked
> library(MethLAB)
> MethLAB()
Warning message:
In file (filename, "r", encoding =encoding) :
unable to resolve 'bioconductor.org'
So the above is what i get when i try to run it. Can anyone help me with its proper installation and running ?
I suspect it is because you are not connected to the internet. Is that so? If it is then you should contact the people that wrote the package; it seems the software is trying to contact BioConductor for some reason, perhaps to download additional packages/functionality etc. To that end, make sure you have installed all the pre-requisite packages needed to run `MethLAB.
Do note that this is a warning only, not an error. Whether this stops the package from working or not is a different matter. Again you should take this up with the developers if you have followed all the instructions on how to install and use the package.

Resources