errors installing 'sads' package - r

I am trying to install the sads package (on a Mac OSX) from the beta version which I have downloaded from:
http://ecologia.ib.usp.br/let/doku.php?id=engl:tutorials:rcode#species_abundance_distributions
I then run:
install.packages('~/Desktop/sads_0.1.03.tar.gz', repos=NULL)
and get the error message:
Error: file ‘~/Desktop/sads_0.1.03.tar.gz’ is not an OS X binary package
Any idea how to resolve this and install the package? It looks really useful.
Thanks.

The file you downloaded is not a Mac OS binary package, which is the default for install.packages. Like #sgibb said, you need to specify type = 'source' to force R to look for a source package that you are then going to build yourself. In case the package only contains R code this is quite straightforward. If code needs to be compiled, this could be a more involved process.

Related

package 'lubridate' installation error: compilation failed for package 'lubridate' [duplicate]

A friend sent me along this great tutorial on webscraping The New York Times with R. I would really love to try it. However, the first step is to install a package called [RJSONIO][2] from source.
I know R reasonably well, but I have no idea how to install a package from source.
I'm running macOS (OS X).
If you have the file locally, then use install.packages() and set the repos=NULL:
install.packages(path_to_file, repos = NULL, type="source")
Where path_to_file would represent the full path and file name:
On Windows it will look something like this: "C:\\RJSONIO_0.2-3.tar.gz".
On UNIX it will look like this: "/home/blah/RJSONIO_0.2-3.tar.gz".
Download the source package, open Terminal.app, navigate to the directory where you currently have the file, and then execute:
R CMD INSTALL RJSONIO_0.2-3.tar.gz
Do note that this will only succeed when either: a) the package does not need compilation or b) the needed system tools for compilation are present. See: R for Mac OS X
You can install directly from the repository (note the type="source"):
install.packages("RJSONIO", repos = "http://www.omegahat.org/R", type="source")
A supplementarily handy (but trivial) tip for installing older version of packages from source.
First, if you call "install.packages", it always installs the latest package from repo. If you want to install the older version of packages, say for compatibility, you can call install.packages("url_to_source", repo=NULL, type="source"). For example:
install.packages("http://cran.r-project.org/src/contrib/Archive/RNetLogo/RNetLogo_0.9-6.tar.gz", repo=NULL, type="source")
Without manually downloading packages to the local disk and switching to the command line or installing from local disk, I found it is very convenient and simplify the call (one-step).
Plus: you can use this trick with devtools library's dev_mode, in order to manage different versions of packages:
Reference: doc devtools
From CRAN, you can install directly from a GitHub repository address. So if you want the package at https://github.com/twitter/AnomalyDetection, using
library(devtools)
install_github("twitter/AnomalyDetection")
does the trick.
In addition, you can build the binary package using the --binary option.
R CMD build --binary RJSONIO_0.2-3.tar.gz

Installing local binary packages using R CMD INSTALL on a Mac

I came across a package that is not available on CRAN. I tried to install the package using:
Packages & Data > Package Installer > Local Binary Package > At User
Level > [FileName.tgz] > Install...
This didn't work and I am now trying to use the R CMD INSTALL command. However, it seems I need to run that command in the command line interface but I cannot get it to install properly.
The package I'm trying to install is called gEcon. It can be found here. In particular, I am getting the following error message after "installing" the package:
Error: package or namespace load failed for ‘gEcon’:
package ‘gEcon’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
I assume it's the way I'm installing it.
Thanks in advance.
You're going to need to install Xcode apparently, because you've got to install this from source per these directions:
Now, you've gotta update R to the latest stable release, or if you prefer you can find the exact minimum newest version needed for gEcon.
After upgrading R you can complete the installation from source.
Original answer to original question:
Two things:
To access the command line and use R CMD on an Apple computer, please use the terminal.app app. Please see this for more details.
An easier and probably better approach is to install your package from the author's Github (or BitBucket, etc) repository using devtools::install_github or just use devtools::install on the downloaded source project.

How to install 'XLConnect'-package in R correctly

I am very new to this community.
My aim is to use R for statistical analysis but some errors occurred.
In the first step, I want to load the "XLConnect"-package, in order to open an xlsx-data file, with this code:
install.packages('XLConnect')
library(XLConnect)
Answer was "package ‘XLConnect’ successfully unpacked and MD5 sums checked", after which the following error was given:
Error in library(XLConnect) : the package ‘XLConnect’ doesn't exist.
I also tried the xlsx package, but in this case always got:
Error in -library('openxlsx') : invalid argument to unary operator
or, that the package openxlsx, doesn't exist but some line before it told me the download, installation and check sums were correct!
Additionally, when I try to change the directory in a script, using
getwd(), the following error occurs:
Error in -getwd() : invalid argument to unary operator
When I type it in the console it works.
I downloaded R here: https://cran.r-project.org/bin/windows/base, installed R version 3.4.3 as well as R Studio.
I already looked in the community for some hints but neither could solve my problem:
XLConnect function is not passing argument to system.file
Error when installing XLConnect in RStudio
MY OS is Windows 10, I tried the 32-bit as well as the 64-bit version of R and installed fitting Java-Versions for both verisons( that was the first error that occured but now isn't there anymore).
I tried to load the packages from several CRAN-Mirrors but always the same error occurs (e.g. Germany(Göttingen),Germany(Münster), Belgium(Ghent) or Switzerland ).
Maybe I missed some very basic setting. Is the information I provided enough or do you need more?
Thanks a lot in advance for your support!
Thanks a lot! I installed java 32-bit and 64-bit versions the way it is recommended here: https://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/ and I installed the rJava package like this: install.packages("rJava")
library(rJava) and here: https://askubuntu.com/questions/176115/what-is-the-best-way-of-installing-the-r-package-xlconnect I found that this here should work to register R correctly: sudo R CMD javareconf but then I get the error that the console got an unexpected symbol. Or Do you know how to register Java Development Kit in R correctly. I installed jdk-8u161-windows-x64.
Make sure you have Java Development Kit installed and correctly registered in R.

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.

Error while installing R package: package built for universal-apple-darwin

I installed a R package as suggested by How do I install an R package from source?, using R CMD INSTALL [my_pkg_path.tgz]. Package sources are downloaded from r-project.org, e.g., http://cran.r-project.org/web/packages/fields/index.html
However, when I try to load the package using say library(fields), I got the error that complains the package are built for universal-apple-darwin:
Error: package ‘fields’ was built for universal-apple-darwin9.8.0
Guess it's something to do with architecture, but no idea how to resolve it. Any idea? Thanks.
It looks like you downloaded the package's Mac OSX binary file, which usually ends in .tgz - try downloading the package source (usually something ending in .tar.gz) and installing the package again.
Depending on what your operating system is, you may need an additional set of software before you can install packages from source. If the above suggestion doesn't work, would you provide some information about the OS, for example from sessionInfo()?

Resources