installing an archived package - r

The package is available on this website.
http://cran.r-project.org/src/contrib/Archive/rlandscape/
When I use:
install.packages("rlandscape",
repos = "http://cran.r-project.org/src/contrib/Archive/rlandscape/",
type="source")
I get the following error:
package 'rlandscape' is not available (for R version 3.1.2)
I have tried older versions too but no luck..

The devtools package has a function that can install archived versions. Try:
library("devtools")
install_version("rlandscape",version="1.0",
repos="http://cran.r-project.org")
(You should be able to use repos=getOption("repos")["CRAN"] instead, but it looks like your repos option is slightly messed up, i.e. the URL is missing the http://.)
(The repos argument is necessary to work around what I think is a glitch in install_version, i.e. it assumes that repos is a length-1 character vector.)
This should, I think, also automatically install appropriate dependencies -- although it's a bit of a catch-22 if they are in the CRANextra repository for Windows, since that has to be suppressed in order to get install_version to work ...
It may also be the case that install_version automatically assumes that you want the package and all dependencies installed as source (not binary) installations, in which case you will need to have compilation tools installed. The rlandscape package doesn't actually have any compiled code included, but its dependencies do ...

This is an old (archived) package that is no longer supported. If you really need it, you can install it using R CMD INSTALL but you need also to install all its dependencies manually.
Installing your desired package gave me the following:
>R CMD INSTALL ~/Downloads/rlandscape_1.0.tar.gz
* installing to library ‘/Users/mohamedahmed/Rlibs’
ERROR: dependencies ‘spatstat’, ‘deldir’, ‘gWidgets’, ‘gWidgetsRGtk2’ are not available for package ‘rlandscape’
* removing ‘/Users/mohamedahmed/Rlibs/rlandscape’
I am not sure all dependencies are still available on CRAN, but it seems to be challenging task.

Related

install dependencies from CRAN for a package installed from source

I want to give a beta version of my package to a coworker for testing purposes.
I build the package and put the .zip file on the Network Folder.
The Problem is, how to tell R that it should install the package from the ZipFile but its dependencies from CRAN?
install.packages("path\\to\\zipfile.zip", source = TRUE, repos = NULL)
Because repos = null disables the dependency resultion. If under stand the documentation correctly:
dependencies
logical indicating whether to also install uninstalled packages which these packages depend on/link to/import/suggest (and so on recursively). Not used if repos = NULL. Can also be a character vector, a subset of c("Depends", "Imports", "LinkingTo", "Suggests", "Enhances").
I would like to give the coworker a short snippet of code to install for himself without him having to interact further with the installation.
As the Imports or dependencies might change in later development, i would prefer not to hardcode them.
I found devtools::install() which satisfies this requirement. Although it needs devtools.

Installing package webr failed

I am having issues installing the 'webr' package in R, which is necessary to use the PieDonut function to make beautiful multi-level pie charts.
I have followed the instructions on this website, which demonstrates how to install the packages and work with it. https://rpubs.com/cardiomoon/398623
However, when installing the package 'webr' it says:
Failed to install 'webr' from GitHub:
(converted from warning) package ‘mnormt’ is not available (for R version 3.6.2)
It is necessary to install it from GitHub because the CRAN version does not include the PieDonut function.
I already tried to search for older versions of the package and made sure that my R version was up to date, however this did not result in any progress.
Does anybody have any suggestions to help me use this package?
You are on R 3.6.2, whereas mnormt requires R 4.0.0 or higher.
Installing an older version of the package can go from easy to "I want to jump out the window" difficult. If you go to the package archive you can find a version that will not depend on newer version of R than you have. You can install it from source with, if I remember correctly, something along the lines of
install.packages("https://cran.r-project.org/src/contrib/Archive/mnormt/mnormt_1.5-7.tar.gz",
repos = NULL,
type = "source")
Assuming all its dependencies do not require something you do not have (i.e. R >= 4.0.0), it should work. If not, you would have to install mnormt dependecies by hand as well, as well as any potential dependencies of dependencies. See what I mean by jumping out of the window?
Alternatively, upgrade your R and you avoid these kinds of problems (in 99.9 % of the time).

R 3.5 package ‘lattice’ was installed by an R version with different internals

I updated R 3.4.4 to R 3.5.0 today. And my package cannot pass R CMD check anymore. It fails at checking whether package can be installed ... ERROR.
In another hand my package works, I can install it and use it as long as I don't check it.
The error is the following:
Error: package or namespace load failed for ‘sp’:
package ‘lattice’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version
Error : package ‘sp’ could not be loaded
I tried to reinstall lattice these ways:
sudo apt-get --reinstall install r-cran-lattice
or
remove.packages("lattice", lib="~/R/x86_64-pc-linux-gnu-library/3.5")
install.package("lattice")
The package lattice is installed correctly in both cases. But it does not solve my problem. Also I ensured to have a single version of lattice removing either the r-cran one or the self compiled version. Nothing works.
Edit By the way I can do library(sp) or library(lattice) it works. But not with R CMD check
The error message tells you that the binary you are attempting to install comes from an insufficient / incompatible R version.
Two fixes:
Install from source as you did. After that check with AP <- available.packages() that you really only have one.
Use the correct binarie: read this README at CRAN and switch to Michael's 'R 3.5' repos. Many of us have been doing that for weeks.
Lastly, the r-sig-debian list is a friendly place for these questions and more. Subscribe first so that you can post.

how to make devtools install_github to install dependency packages from CRAN instead of compiling source

EDIT: see edit in end.
I have a R package in github and I'm using devtools::install_github to install it, which also install dependency packages.
Recently this process will install httpuv as source package, but compiling it in Mac meet errors with automake (something like this). I installed automake, then there was error with clang: error: unsupported option '-fopenmp'.
The issue and the possible solutions 1 2 seemed to be quite complicated. I think the CRAN version of httpuv probably will work for me, and I don't want my users to go through so many errors and fixing compiler errors.
I'd like to just install all dependency packages from CRAN in binary. For some packages that do need the more up to date version, I have specified it in my package description with remote section.
I checked install_github, then install, then install.packages. It seemed that the default behavior for binary vs source package is
An alternative (and the current default) is "both" which means ‘use
binary if available and current, otherwise try source’. The action if
there are source packages which are preferred but may contain code
which needs to be compiled is controlled by
getOption("install.packages.compile.from.source").
My getOption("install.packages.compile.from.source") is interactive. This is actually a preferred behavior for me. However I never see the interactive prompt.
I tried to give a type = "binary" parameter in install_github, but it doesn't seem to work, maybe it's not passed to every dependency package install?
EDIT:
I found the situation is a little bit more complex:
my app specified to install shiny github version via remote in description. shiny specified to install httpuv github version in remote section too. So this is actually the intended behavior.
I'm not sure if there is a solution available, other than require CRAN version of shiny in my package.
EDIT 2: It's more complex than my previous findings.
I removed remote section in my package description, supposedly only CRAN version is needed. However install_github still install most dependencies from github.
I finally found out that I have these dependencies github version installed, so their description in my local disk have the github remote information, and install_github found this information and "upgrade" them again, even when some of them have no change.
So I need to uninstall them first, only use CRAN version.
The really problem here is that if a dependency package is already new, it should not be installed. It could be a bug of devtools.
install_github passes arguments to devtools::install, and there upgrade_dependencies= FALSE and maybe even dependencies = FALSE might be what you're after:
install_github("you/urPackage", upgrade_dependencies = FALSE)

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

Resources