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

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()?

Related

Difficulty installing a package in R linux, dalton_rqi

Downloaded package from below URL.
Attempted to install using below command; response shown.
library(dalton.rqi,lib.loc='/home/X/Desktop/')
Error: package ‘dalton.rqi’ was built before R 3.0.0: please re-install it
https://my.clevelandclinic.org/departments/anesthesiology/depts/outcomes-research/risk-quantification
It appears this is a compiled package that maybe I don't have the source for? Is there a way to force install of the package? I'm unable to install using Rstudio GUI in its current form as a zip. Tried repackaging to tar.gz has Rstudio was looking for and also had a non-zero exit status error.
Any ideas?
I'm afraid this can't be achieved directly. The error message says it well: to use a package in R it needs to be built on an R version matching yours.
I can suggest two ways to move forward:
Contact the authors, ask for the R sources (it is somewhat surprising they did not make them available in the first place), and build the package yourself.
Downgrade your R version as far back as needed to match the one this pre-built package used.

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.

Install package "locClass" in R

I want to install a package named "locClass" in R but always failed and kept getting the following warning:
install.packages("locClass", repos="http://download.r-forge.r-project.org/")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘locClass’
These will not be installed
The install command is referred to: https://r-forge.r-project.org/R/?group_id=1187
Also, I downloaded the package source from the above website. But R returned the following:
library(locClass)
Error in library(locClass) : ‘locClass’ is not a valid installed package
My R version is 3.3.3. I tried the 3.4.0 but failed the same way.
This is not exactly a solution but an alternative to utilize functionality of package locClass. Download the package file of locClass from here and source(functions.R) present here. This way you can use all functions available in package.
Note : function.R means FLXMCL.R, FLXMCLconstant.R etc.
I'm still looking for a better solution but this is a temporary alternative.

Error in R: (Package which is only available in source form, and may need compilation of C/C++/Fortran)

I'm trying to install the 'yaml' and 'stringi' packages in R-Studio, and it keeps giving me these errors:
> install.packages("stringi")
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘stringi’
These will not be installed
or
> install.packages('yaml')
Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘yaml’
These will not be installed
How can I get these to install properly?
The error is due to R being unable to find a binary version of the package on CRAN, instead only finding a source version of the package and your Windows installation being unable to compile it. Usually this doesn't occur, but in this case was caused by the (temporary) outage of some of the mirrors at CRAN. If you type:
> getOption('repos')
CRAN CRANextra
"http://cran.rstudio.com" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
You will see that R uses "http://cran.rstudio.com" by default to look for a package to download. If you see the cran mirrors web page you can see at the top that "http://cran.rstudio.com" actually redirects you to different servers world wide (I assume according to the geo location).
When I had the above issue, I solved it by manually changing the repo to one of the urls in the link provided. I suggest you use a different country (or even continent) in case you receive the above error.
I provide below some of the urls in case the link above changes:
Brazil http://nbcgib.uesc.br/mirrors/cran/
Italy http://cran.mirror.garr.it/mirrors/CRAN/
Japan http://cran.ism.ac.jp/
South Africa http://r.adu.org.za/
USA https://cran.cnr.Berkeley.edu/
You need to run the function install.packages as follows:
install.packages('<package_name>', repo='http://nbcgib.uesc.br/mirrors/cran/')
#or any other url from the list or link
One of them should then work to install a binary from an alternative mirror.
You need to install RTools to build packages like this (i.e., a source package rather than a binary). After you install Rtools, then try again to install.packages("ggplot2") and R will prompt you with:
Do you want to attempt to install these from source?
y/n:
(see the picture below)
You need to answer y and it will try to compile the package so it can be installed.
Struggled with this issue today, solved it for now by first downloading the windows binary and then installing e.g.
install.packages("https://cran.r-project.org/bin/windows/contrib/3.3/stringi_1.1.1.zip", repos =NULL)
Just go to https://cran.r-project.org/ and then R Binaries/Windows/contrib and copy the url as argument to install.packages()
Install the package from a zip file - downloadable from the r-project website.
In basic R
go to Packages
Install packages from local files.
In RStudio
go to Packages
Install packages
Install from Package Archive File.
I had this issue when using an out-of-date version of R, so no binaries were available. The simple solution was to update my version of R.
Anything worked for me, until I found out my computer had an old version of R installed. Uninstalling everything and installing the newest R version worked!
I had to download the latest version of Rtools:
Go into the downloads folder and double click it to install it.
Close and reopen any R session.
Now packages should install like normal.
However, if you still have trouble, try installing the package from source (using type="source")
Like this:
install.packages("dplyr", type="source")

errors installing 'sads' package

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.

Resources