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

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).

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.

unable to access index for repository in R

I am on Windows 7 and I am using R Studio 0.99.902 with R3.3.1. When I am trying to install a package I get the Warnings:
Warning: unable to access index for repository http://cran.rstudio.com/src/contrib:
cannot open URL 'http://cran.rstudio.com/src/contrib/PACKAGES'
Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib:
cannot open URL 'http://www.stats.ox.ac.uk/pub/RWin/src/contrib/PACKAGES'
It is the first time I see it and I cannot solve it. Can anyone help me ?
This issue is likely caused by the package being too old or too new for your R version. For example, if a package is released during R-3.4.1, it will not be available for R-3.3.1. Packages which are removed from CRAN before your R version are also not available. The package DESCRIPTION file shows if there is a hard restriction on which R versions the package will run.
Search for the package's CRAN page and see its status. You may still be able to install the package by downloading the package source (the tar.gz file) and in RStudio selecting Install from: Package Archive File in the Tools/Install Packages... menu (or using install.packages with repos = NULL). Beware that the package is not available from CRAN for a reason; you may need to make some changes to the package for it to work correctly.
Running options(download.file.method="libcurl") then installing packages did the trick for me. You may find an answer here.
Please note that compiling from source for Windows requires the appropriate version of Rtools that is compatible with the R version you are working with. This list is available at the Rtools site:
https://cran.r-project.org/src/contrib/Archive/
If compilation from source is complicated, it is also possible to find the Windows-compiled binaries (.zip files) for older versions of R at:
https://cran-archive.r-project.org/bin/windows/contrib
This link is referenced by the ReadMe file available at the "regular" repository for Windows binaries for different versions of R, namely at:
https://cran.r-project.org/bin/windows/contrib
Once the zip file is downloaded, you can run the following R code line to install the package:
# Use repos=NULL so that the first argument is a path to the local zip file
# containing the binary package to install
# (as opposed to just the name of the package to install from the web)
install.packages("<local-path-to-downloaded-zip-file>", repos=NULL)

Is the bigvis package for R not available for R version 3.0.1?

I'm developing an app designed to handle big data and was having problems graphing the data in a useful way because of the sheer amount of plot points. My initial idea was to create a little algorithm that, based on the size of the data, divides the data points into about 30 subsets and takes the average of all the points in these subsets (what are the faults of this implementation by the way)?
Then I learned about bigVis, which does a lot of the big data representation for you, and I really want to try this library out.
I have a problem installing it. I've done:
>install_github("devtools")
>install.packages("bigVis")
Warning in install.packages :
package ‘bigVis’ is not available (for R version 3.0.1)
I've also done:
>install_github("devtools")
>devtools::install_github("bigvis")
* installing *source* package 'bigvis' ...
** libs
*** arch - i386
ERROR: compilation failed for package 'bigvis'
* removing 'C:/Program Files/R/R-3.0.1/library/bigvis'
Error: Command failed (1)
Does anyone know what this error is?
Thanks
assuming you've got Rtools.exe installed, here are the steps to get bigvis installed if it still does not work. you need a 64-bit compiler in order to run the Rcpp package, one of the dependencies of bigvis
in R, confirm g++ isn't installed (or isn't 64-bit)
Sys.which( "g++" )
download mingw-w64 - http://sourceforge.net/projects/mingw-w64/ (Since the mingw-w64 project on sourceforge.net is moving to mingw-w64.org i suggest to use mingw-w64.org)
when the mingw-w64 installer pops up, be sure to change the architecture row from i686 to x86_64 then let it install
in the windows start menu search bar, type environment and an option edit the system environment variables should pop up. click it.
edit your PATH and add a semicolon plus the folder name of the bin directory of the mingw-w64 program that you just installed. for me, it was ;C:\Program Files\mingw-w64\x86_64-4.9.0-posix-seh-rt_v3-rev2\mingw64\bin but this will change for future versions
close & re-open R and Sys.which('g++') should now indicate the mingw-x64 directory
Sys.which('g++')
"C:\PROGRA~1\MINGW-~1\X86_64~1.0-P\mingw64\bin\G__~1.EXE"
devtools:::install_github("hadley/bigvis") should now complete successfully
This works for me, using R v 3.0.1 on Windows 7.
Directly download the current package from GitHub:
download.file("https://github.com/hadley/bigvis/archive/master.zip", destfile = "bigvis.zip")
Unzip it, just so that we leave nothing to chance (though you could use the .zip itself):
unzip("bigvis.zip")
and install from source:
install.packages("bigvis-master", repos = NULL, type = "source")`

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.

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