Using R, how to install github library without `devtools` - r

Let's say I wanted to install a library off of github without devtools. How would I do that?
I was helping a student in office hours today, and devtools required a lot of dependencies. It took nearly a half-an-hour just to get him ready to use it. I know that install.packages works for local files, is the github setup going to enable this?
Let's say: https://github.com/laresbernardo/lares
I understand that devtools::install_github is just a wrapper for remote::install_github which explains some of the dependency issues with these packages (and tidyverse in general - haven was broken today for Windoze).
Can I not install a package directly using install.packages from R:base using the remote source?

Related

Discrepancies between R-package on github and install_github install

I am working on my package, which is hosted on github, using Visual Studio Code (1.67.1). I am using github desktop to push changes to the repository on github. This process works well. However when I re-install my package using:
library(devtools)
install_github("Ellesaere/tkis.package", dependencies=TRUE, force=TRUE)
I often find that an older version is installed, even though the github repository shows the correct version. I cannot figure out what makes it work, or not work. This is getting extremely frustrating, as I continuously find myself restarting R, reinstalling the package, hoping that it installs the correct version this time.
I was wondering if anyone could give some reasons why this could be happening.

How can I deal with self-written R-packages when using Renv?

In our team, we are sharing self-written functions (e.g. for connecting to our dbs) via a self-written package that I set up in a git-repository (non-public).
As a general rule, we avoid to install packages in our users' accounts. Instead we use renv to get reproducible environments. How can I best handle the private package with renv?
Can I somehow use renv::install() to install the package from the private git-repo with ssh-keys?
What I've done so far: I cloned the package and installed it via R CMD INSTALL path/to/folder_with_tar.gz. renv does not seem to pick up the package when running renv::init() / renv::snapshot(). I am working on using devtools to install from repository (currently waiting for IT to resolve git2r issue) but this would not solve the problem with renv.
Sorry for no MWE, I don't know how to produce one in this case.
EDIT 2022-11-08:
I want to keep this question open because this is not an answer to the question but rather a workaround. However, if using RStudio with a professional license, the best solution is to use the Package Manager. This circumvents the problem a bit: Instead of dealing with how to acces the private git from renv, the Package Manager manages the access.

Install R packages outside R

So the thing is my IT department is scared of R and therefore only allows us to use it on a laptop that can't go online. Therefore they are the ones to install packages on it.
But due to covid I'm at home discovering they didn't install the requested packages. So I'm looking to see if there is a way to download these packages on a laptop with internet access, add them to an USB and then install them from the USB in R?
Quite easy, just download the package from the CRAN site e.g. https://cran.r-project.org/web/packages/imputeTS/
You can either download the "Package source" or the "Binaries" (must be your operating system.
If you are using R Studio, there is then even a menu item for installing the package - just select the file you downloaded and here you go.
If you are not using R Studio, just provide the path to your downloaded archive in the install.packages command.
The only problem is, you also need all the dependencies ...;)
So you ideally already have them and just one package is somehow missing - otherwise this can get quite time consuming to download all the dependencies - because the dependencies itself also usually have dependencies themselves...
In this case the miniCRAN solution Roland linked in the comments might be an idea. ( Offline installation of a list of packages: getting dependencies in order ) But didn't try the miniCRAN myself yet - would be interested how good this actually works.

(More) DeclareDesign R Package download problems

I asked a similar question a couple months ago, but the package, website, and code in question have since been updated and the solution I used previously is no longer effective.
The issue is that I am unable to install a particular package in R.
The new code provided for installation of the DeclareDesign package is as follows (source):
install.packages("devtools")
devtools::install_github("DeclareDesign/DeclareDesign")
I've provided a screenshot of the error that I get when I try to run the above code. It looks to me like the problem is with the included 'estimatr' package, which apparently then causes the entire installation to fail.
How do I get this to work?
Your installation failed because devtools is trying to install estimatr from source, but you don't have the appropriate toolchain available to build it.
DeclareDesign now has a drat repository with pre-built binary packages for Mac and Windows, which should obviate the need to install Xcode or Rtools.
install.packages("DeclareDesign", repos="http://r.declaredesign.org")
DeclareDesign is now on CRAN, so you can install via
install.packages("DeclareDesign")

Package installation issues with R 3.1.0

My Fedora system (Fedora 20, all up to date) has just had R updated to version 3.1.0. Since then, I've had issues installing multiple packages. glmnet failed previously, and now I'm having trouble with treemap. More specifically, I get an error during treemap installation that httpuv has zero exit status.
I never had issues with the previous version of R. Any reason this version should have such problems??
There could be many causes to do with your OS, version, permissions, other installed packages/software, etc, etc. Without seeing the full error message it's hard to know.
One possibility specific to httpuv is root privileges. I've noticed a few threads on various forums when searching for installation errors with this package and Linux, many of them mentioning root v. non-root issues. In another case, libuv needed to be upgraded.
I encounter package installation problems daily and I have some more general work-arounds as well. Hopefully one of these will solve your problem.
Install the package from source
download.file(url="http://cran.r-project.org/src/contrib/httpuv_1.3.0.tar.gz", destfile = "httpuv.tar.gz")
install.packages("httpuv.tar.gz", type = "source", repos = NULL)
Install using devtools via GitHub if the package supports it
Install RTools and re-try your package installation
Install an older version of the package
If those above do not work, then I dig deeper by referring to advice given to me by a VP of IT in my company. These comments were made in reference to frequent package installation problems I encountered when switching from Windows to Solaris:
There are two types of install/make problems. Missing .h files
and/or missing .so/.a libs. The reason for these are multiple:
1.- the package that delivers these is not installed. This means that those files cannot be found anywhere in the /usr tree. Solution is
install right package, make sure the files are there
2.- the includes are not found by the install configurator. This means some environment variable or install option is not properly set (this
is our case for RODBC). Figuring out which variable to set is
challenging without looking at the package documentation [fortunately, documentation is not hard to find!]
3.- the libs are not in the LD_LIBRARY_PATH, easy to fix.
4.- There is a deeper compile/link error, meaning the package is not compatible with the rest of the sw, or has not been properly ported.

Resources