I am trying to install the package ‘RGoogleTrends’ in R but it says package ‘RGoogleTrends’ is not available (for R version 2.15.2). Any help in this regard will be highly appreciated.
Whilst it may not be available via install.package('RGoogleTrends', repos = "http://www.omegahat.org/R", type = "source"), you can download the package tar file http://www.omegahat.org/RGoogleTrends/RGoogleTrends_0.2-1.tar.gz and install from
the downloaded file, something like
install.packages("~/Downloads/RGoogleTrends_0.2-1.tar.gz", repos = NULL, type = "source")
replacing the path with the path on your system.
Note that RGoogleTrends imports the packages
RCurl, RSQLite, DBI
You may need to separately install these packages (with repos set to an appropriate non NULL value)
Related
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.
I have developed a local package that depends on others available on CRAN (as an example, pool). Therefore, when I attempt to install the package using the standard
install.packages("/path/to/package",
repos = NULL,
type = "source")
I get an error because the dependencies aren't installed. install.packages has an argument dependencies which by default would try to install those dependencies. However, as stated by the man page (and commented in the linked question below), repos = NULL means the dependencies are ignored.
To get around that, I used package miniCRAN to create a repo containing my package, hoping I could do a repos = c("myRepo", getOption("repos")) to get it to work.
Now I can install my package using
install.packages("package",
repos = c("/path/to/repo", getOptions("repos"),
type = "source")
But only if I've already installed pool. If not, I still get an error because it can't find the dependencies.
So I called miniCRAN::addPackage("pool"), which adds that package and its many dependencies to my repo, and they all appear if I call miniCRAN::pkgAvail().
However, if I attempt to install my package again, I still get a there is no package called 'pool' error.
Interestingly, if I try to install pool itself from the repo, it works.
install.packages("pool",
repos = "/path/to/repo",
type = "source")
install.packages("package",
repos = "/path/to/repo",
type = "source")
Obviously, however, this kind of beats the point of adding pool to the repo: I might just as well have installed it from CRAN.
So what's going on here, and is this really the only way to install local packages and their CRAN dependencies?
Figured it out.
The problem was a misunderstanding on my part regarding roxygen, which I've been using for my documentation. I assumed it handled the Imports: section of the DESCRIPTION file, which it doesn't ((1), (2)). So while the NAMESPACE file has all the necessary importFrom(pool, ...) calls, pool wasn't actually on my DESCRIPTION.
After fixing that oversight, using remote::install_local("path/to/pkg") (or devtools::install()) ((3)) worked: it installed my package and pulled its dependencies from CRAN.
I have a problem with installing package (gahgu95av2.db) in R. How can I deal with this? Please see below
It seems that gahgu95av2.db has been dropped from Bioconductor versions >3.3. However you can still install the package from source.
Download the source file
Go to the folder with gahgu95av2.db_2.0.1.tar.gz; then open an R terminal and do
install.packages(
"gahgu95av2.db_2.0.1.tar.gz",
repos = NULL,
type = "source");
Is there any reasonable way to install a CRAN package alongside a github package of the same name?
Specifically, I am after the geom_sf() geom in the sf branch in the ggplot2 github page: https://github.com/tidyverse/ggplot2/tree/sf. So I can install the sf branch like this:
devtools::install_github("tidyverse/ggplot2", ref = "sf")
And the CRAN version like this:
install.packages("ggplot2")
However, the sf branch is behind ggplot2 in other useful features so I don't want to completely revert. So I am wondering what the best approach is here. Can I install both but somehow call one package ggplot2_sf? Basically I want to be able to use geom_sf with the all the functionality of ggplot2 that is currently on CRAN.
I had thought that maybe the best solution was to fork the ggplot2 repo, merged the master and sf branches then install that. But I am wondering if there is a better way?
Update
So it turns out that you need to specify the lib directory using withr (see here). I tried this:
withr::with_libpaths(new = "./R/gh_libs/", install_github("tidyverse/ggplot2", ref = "sf"))
This returned this error:
Error in curl::curl_fetch_disk(url, x$path, handle = handle) :
Problem with the SSL CA cert (path? access rights?)
So I can set the SSL certification to zero like this:
httr::set_config( httr::config( ssl_verifypeer = 0L ) )
withr::with_libpaths(new = "./R/gh_libs/", install_github("tidyverse/ggplot2", ref = "sf"))
But then this doesn't install this in the directory I am after:
Downloading GitHub repo tidyverse/ggplot2#sf from URL
https://api.github.com/repos/tidyverse/ggplot2/zipball/sf Installing
ggplot2 Installing 1 package: digest Warning in
utils::install.packages(pkgs, repos = repos, type = type, dependencies
= dependencies, : 'lib = "C:/Program Files/R/R-3.3.3/library"' is not writable Error in utils::install.packages(pkgs, repos = repos,
type = type, dependencies = dependencies, : unable to install
packages
Any other ideas of what I might be doing wrong?
You can use devtools::dev_mode() for this. From the man page:
When activated, dev_mode creates a new library for storing installed packages. This new library is automatically created when dev_mode is activated if it does not already exist. This allows you to test development packages in a sandbox, without interfering with the other packages you have installed.
I have an error when installing packages offline when they have dependencies. This is very similar to this question. I have followed the instructions there to do the offline install.
So I have installed all the CRAN packages to a directory and created the PACKAGES file also.
But there seems to be a subtle bug with the process outlined in that answer
I can install a package from the local repo on Linux with no problem using the command below i.e. not specifiying the repo:
install.packages("/software/r_packages/src/contrib/ZillowR_0.1.0.tar.gz", lib="/usr/lib64/R/library")
However, if I want to pick up the dependencies I need to point it towards the repo and its PACKAGES file using e.g.
install.packages("/software/r_packages/src/contrib/ZillowR_0.1.0.tar.gz", lib="/usr/lib64/R/library", repos="file:///software/r_packages/")
But if I do this I get the error:
Warning message:
package ‘/software/r_packages/src/contrib/ZillowR_0.1.0.tar.gz’ is not available (for R version 3.2.3)
I've tested and confirmed it is reading the PACKAGES file because if I put a typo into the entry for ZillowR in PACKAGES I get an error indicating it can't parse the entry correctly.
What should work for you here is the following:
install.packages(pkgs = "ZillowR", type = "source",
lib = "/usr/lib64/R/library",
contriburl = "file:///software/r_packages/")
The arguments to install.packages() can be pretty overwhelming and all of the defaults are configured to work with packages installed from CRAN (or another remote repository). To unpack what is going on here, consider the following code to install ZillowR from CRAN:
install.packages(pkgs = "ZillowR")
This is setting lots of defaults, so you're actually calling:
install.packages(pkgs = "ZillowR", lib = .libPaths()[1],
repos = getOption("repos"),
contriburl = contrib.url(repos, type),
type = getOption("pkgType"))
The two key defaults are calling some global options, which on my install are set to:
> getOption("repos")
CRAN CRANextra
"https://cloud.r-project.org" "http://www.stats.ox.ac.uk/pub/RWin"
> getOption("pkgType")
[1] "both"
You need to (potentially) overcome these defaults into order to do a local install and the key one to overcome is the value of contriburl (which inherits from repos. Knowing that, your intuition appears (rightly) to have been to follow the instructions for installing a local source package, such as:
install.packages(pkgs = "/software/r_packages/src/contrib/ZillowR_0.1.0.tar.gz", repos = NULL, type = "source")
But the behavior of install.packages() is totally different there because the pkgs argument is expecting the filename of a source tarball (when repos and thus contriburl is NULL).
With a local CRAN-like repo, you actually want to set pkgs to the package name and to set contriburl to the local repo path. As a reference here's the relevant section of the docs for contriburl:
contriburl URL(s) of the contrib sections of the repositories. Use this argument if your repository mirror is incomplete, e.g., because you burned only the ‘contrib’ section on a CD, or only have binary packages. Overrides argument repos. Incompatible with type = "both".
The last sentence shows why you (may) need to set type = "source".