How can I install a R package on a offline Debian machine?
Shiny has a few package dependencies, and "R CMD INSTALL" won't find them for you, so you need to get them manually. According to the description of shiny, it's dependencies are:
'Rcpp’, ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’.
So first, get the packages from cran (below are current versions, but they do change over time. Note below is for the computer connected to the internet, you'll need to scp these to the offline computer before continuing):
wget https://cran.r-project.org/src/contrib/Rcpp_0.12.4.tar.gz
wget https://cran.r-project.org/src/contrib/httpuv_1.3.3.tar.gz
wget https://cran.r-project.org/src/contrib/mime_0.4.tar.gz
wget https://cran.r-project.org/src/contrib/jsonlite_0.9.19.tar.gz
wget https://cran.r-project.org/src/contrib/digest_0.6.9.tar.gz
wget https://cran.r-project.org/src/contrib/htmltools_0.3.5.tar.gz
wget https://cran.r-project.org/src/contrib/R6_2.1.2.tar.gz
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
Then go through them in that same order with R CMD INSTALL. eg:
R CMD INSTALL Rcpp_0.12.4.tar.gz
Once all the dependencies are there, R CMD INSTALL should let you install shiny.
Installing a package offline from GitHub
Let's assume that you have Rtools and devtools on the win machine.
Step 1: Download the source zip.
Step 2: Copy to the win machine and unzip the content there.
Step 3: Run the following code (adjust the path as necessary):
library(devtools)
source <- devtools:::source_pkg("E:/temp/data.table-master")
install(source)
library(data.table)
#loads 1.9.7
Manually Downloading and Installing Packages in R
You can install the package manually using the following command
install.packages('package.zip', lib='destination_directory',repos = NULL)
See the help of ?install.packages
, for further description
How to install R packages that are not available in R-essentials ?
Now I have found the documentation:
This is the documentation that explains how to generate R packages that are only available in the CRAN repository:
https://www.continuum.io/content/conda-data-science
Go to the section "Building a conda R package".
(Hint: As long as the R package is available under anaconda.org use this resource. See here: https://www.continuum.io/blog/developer/jupyter-and-conda-r)
alistaire's answer is another possibility to add R packages:
If you install packages from inside of R via the regular install.packages
(from CRAN mirrors), or devtools::install_github
(from GitHub), they work fine. @alistaire
How to do this:
Open your (independent) R installation, then run the following command:
install.packages("png", "/home/user/anaconda3/lib/R/library")
to add new package to the correct R library used by Jupyter, otherwise the package will be installed in /home/user/R/i686-pc-linux-gnu-library/3.2/png/libs mentioned in .libPaths() .
Installing an R package from local unzipped folder
If it is an unzipped Windows binary (e.g., from CRAN), you can just copy and paste the entire package directory into your library folder. You could also, presumably, use file.copy()
to do so if you wanted to do it within R. install.packages()
is failing (weirdly) because you're giving it something other than the typical package source or zipped binary that it is expecting.
Only download sources of a package and all dependencies
There are now better options for this in the tools package that comes with base R: package_dependencies()
. See for example, the Answer from @sebastian-c and this recent Q&A for a related use-case.
There is an unexported getDependencies()
function in the utils package. I haven't studied how it works, but combining that with @Dirk's Answer should get you most of the way there.
Basically though, it appears you use it like:
utils:::getDependencies(pkgs, dependencies, available, lib)
where pkgs
is the character vector of packages to install, dependencies
is a character vector of types of dependencies (Depends, Enhances etc) that you want, available
is the output from available.packages()
and lib
is the library location for the packages within which dependencies are evaluated.
If you debug install.packages()
it is basically doing the getDependencies()
step then @Dirk's download.packages()
step before it actually starts installing anything.
Related Topics
Avoid String Printed to Console Getting Truncated (In Rstudio)
Equivalent to Unix "Less" Command Within R Console
How to Change 'Maximum Upload Size Exceeded' Restriction in Shiny and Save User File Inputs
Referring to Data.Table Columns by Names Saved in Variables
Delete "" from CSV Values and Change Column Names When Writing to a CSV
Detach All Packages While Working in R
Differencebetween Parent.Frame() and Parent.Env() in R; How Do They Differ in Call by Reference
Generate Paired Stacked Bar Charts in Ggplot (Using Position_Dodge Only on Some Variables)
Directly Creating Dummy Variable Set in a Sparse Matrix in R
Data.Frame Without Ruining Column Names
Replace Values in a Vector Based on Another Vector
Group Integer Vector into Consecutive Runs
Delete Columns/Rows with More Than X% Missing
Connecting Across Missing Values with Geom_Line
Why Does Merge Result in More Rows Than Original Data
Create Frequency Tables for Multiple Factor Columns in R