install R packages automatically [duplicate] - r

This question already has answers here:
How to install dependencies when using "R CMD INSTALL" to install R packages?
(7 answers)
Closed 9 years ago.
I created a R package. The DESCRIPTION file of this package is as follows:
Package: Ralgotree
Type: Package
Title: package about securiy information
Version: 1.0
Date: 2013-02-15
Author: algotree
Maintainer: algotree<dinoop#algotree.com>
Description: package about securiy information
License: GPL(>=2)
Suggests: RJSONIO,stringr,RSQLite,bigmemory,Rook,compare,plyr,lubridate,xts
Depends: RJSONIO,stringr,RSQLite,bigmemory,Rook,compare,plyr,lubridate,xts
It depends on other packages like RJSONIO,stringr etc.
So whenever i try to install my package in other machine using the following commands
R CMD build Ralgotree
R CMD INSTALL Ralgotree
it showing the following error messages:
* installing to library ‘/usr/local/lib/R/site-library’
ERROR: dependencies ‘RJSONIO’, ‘stringr’, ‘RSQLite’, ‘bigmemory’, ‘Rook’, ‘compare’, ‘plyr’, ‘lubridate’, ‘xts’ are not available for package ‘Ralgotree’
So i need to do install all packages like this install.packages("RJSONIO").
Is it possible to install all uninstalled packages when we run R CMD INSTALL Ralgotree command?
Thanks

Try,
install.packages("mypkg", dependencies = TRUE)

I do not see that as an option in the arguments listed when I run:
R CMD INSTALL --help
The install.packages R function does have a "dependecies" argument which when TRUE (or the proper character vector) will gather a list of packages from the Description file and install them as well.
?install.packages

Related

Compile R package "arulesSequence" for older release

I want to use arulessequences for sequence mining. I have to use it in Oracle R distribution version R 3.3.0 (last released) and The problem is that the last version of the arulesSequences package is R >= 3.3.2. So I get an error for this problem:
Error: this is R 3.3.0, package arulesSequences needs >=3.3.2
So I decided to compile the source code for older release. I downloaded an older package that needs R 3.2.5 or above. And I know that this package is depended to arules. so I have installed it already. I used following instructions to compile the arulessequences package:
in the source directory I run this command:
R CMD build arulesSequences
the output of this command is:
c:\rr\arulesSequences_0.2-17>R CMD build arulesSequences
* checking for file 'arulesSequences/DESCRIPTION' ... OK
* preparing 'arulesSequences':
* checking DESCRIPTION meta-information ... OK
* cleaning src Warning in cleanup_pkg(pkgdir, Log) : unable to run 'make clean' in 'src'
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* looking to see if a 'data/datalist' file should be added
* building 'arulesSequences_0.2-17.tar.gz'
a file named 'arulesSequences_0.2-17.tar.gz' get created but when I check it as below I get the following as output:
c:\rr\arulesSequences_0.2-17\arulesSequences>R CMD check arulesSequences
* using log directory 'c:/rr/arulesSequences_0.2-17/arulesSequences/arulesSequences.Rcheck'
using R version 3.4.0 (2017-04-21)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
checking for file 'arulesSequences/DESCRIPTION' ... OK
this is package 'arulesSequences' version '0.2-17'
checking package namespace information ... OK
checking package dependencies ... ERROR Package required but not available: 'arules'
See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.
* DONE Status: 1 ERROR
I know the arules package is installed and I checked it. It seems the build process is not successful. do you have any idea to help solve this out?
You have to first install c/c++ compiler for R(called gcc) that is under R's additional build tools.
to do that, in RStudio goto File->New File ->c++ File.
It will show the following dialogue:
Then click on yes.
to compile a package under windows, you have to set repo to Null and type to source.
you can use this command to do that:
install.packages("SOURCEADDRESS",type="source",repo=null)
as #EugèneAdell mentioned above you have to first install arules. then arulessequences.
Instead of building, take the archive packages that seem to be ok for your R version and install them. On my Linux, this gives :
wget http://cran.univ-paris1.fr/src/contrib/Archive/arules/arules_1.5-0.tar.gz
R CMD INSTALL $HOME/arules_1.5-0.tar.gz
* installing to library ‘/home/ruser/R-3.2.5/lib64/R/library’
* installing *source* package ‘arules’ ...
...
** testing if installed package can be loaded
* DONE (arules)
wget http://cran.univ-paris1.fr/src/contrib/Archive/arulesSequences/arulesSequences_0.2-17.tar.gz
R CMD INSTALL $HOME/arulesSequences_0.2-17.tar.gz
* installing to library ‘/home/ruser/R-3.2.5/lib64/R/library’
* installing *source* package ‘arulesSequences’ ...
...
** testing if installed package can be loaded
* DONE (arulesSequences)
R
> library(arulesSequences)
Loading required package: arules
Loading required package: Matrix
Attaching package: ‘arules’
Maybe a more recent version for arules is possible, I just took the first one from the 1.5 series.

R: how to install from internet repos the dependencies of a package we install from local folder

I have developped a R package and added some dependant CRAN package in the description file.
I then install it using install.packages
Is there a way to ensure that its dependencies are fetched at this moment from internet?
In your DESCRIPTION file you should add the lines:
Depends:
package1 (>= 1.0.1),
package2
The (>= 1.0.1) is for specifying minimal version.
More infos here: http://r-pkgs.had.co.nz/description.html

How to install GGRAPH package to the latest R (v.3.3.2)

I am very new to R and I need ggraph library and it can't be installed from rstudio console. Here is a message:
Warning in install.packages : package ‘ggraph’ is not available (for
R version 3.3.2)
Are there other ways of installation? Looks like this library lives and flourishes:
https://www.r-bloggers.com/introduction-to-ggraph-layouts/
This requiresudunits2 library.
I use conda R, so I installed it using conda install -c ioos udunits2=2.2.20. You need to use a package manager to get it installed.
Then install the udunits2 R package
install.packages('udunits2', type = "source",
configure.args=c('--with-udunits2-lib=/Users/Karthik/anaconda/lib'))
Replace /Users/Karthik/anaconda/lib with the path to your R libraries. You can find it using .libPaths()
Finally install the development version of R packages
devtools::install_github("thomasp85/ggraph", dependencies=TRUE)

Dependencies 'dplyr','XML'not available for package <pkg>

I am creating an R package I have completed the R CMD Build and R CMD Check and removed all warnings. I am trying to install the <package>.tar.gz on another machine to see whether it goes through fine. But I get this error
> install.packages("cricketr_0.0.9.tar.gz",repos=NULL,type="SOURCE",dependency=TRUE)
ERROR: dependencies 'dplyr', 'plotrix', 'ggplot2', 'scatterplot3d', 'forecast', 'lubridate', 'XML' are not available for package 'cricketr'
Depends:
R (>= 2.15.0)
Imports:
dplyr,
plotrix,
ggplot2,
scatterplot3d,
forecast,
lubridate,
XML
URL: https://github.com/tvganesh/cricketr
While installing on a new system from the tarball should I manually install dependent packages since it will be available once the package is in CRAN?
Any help will be appreciated
In my experience, dependencies are met once you install from a distribution platform like CRAN or GitHub. Note also that in ?install.packages it says:
Not used if repos = NULL.

R version 3.0.2 cannot find RCurl package

I'm using R version 3.0.2 on my Windows 7 (32-bit) system and am stumped trying to install rCharts. I've had no problem installing other packages from github (e.g., slidify), but R seems unable to find the dependent RCurl package I installed.
I can submit the following basic lines of code without error:
require(devtools)
library(bitops,lib.loc='c:/R/packages/')
library(RCurl,lib.loc='c:/R/packages/')
require(RCurl) # have also tried the library function without luck*
But, when I submit the command to install rCharts with
install_github('rCharts', 'ramnathv')
I get the following :
Installing github repo(s) rCharts/master from ramnathv
Downloading rCharts.zip from https://github.com/ramnathv/rCharts/archive/master.zip
Installing package from C:\Users\nakamura\AppData\Local\Temp\RtmpwzYzaG/rCharts.zip
Installing rCharts
"C:/PROGRA~1/R/R-30~1.2/bin/i386/R" --vanilla CMD INSTALL \
"C:\Users\nakamura\AppData\Local\temp\RtmpwzYzaG\rCharts-master" \
--library="C:/Program Files/R/R-3.0.2/library" --with-keep.source \
--install-tests
**ERROR: dependency 'RCurl' is not available for package 'rCharts'**
*** removing 'C:/Program Files/R/R-3.0.2/library/rCharts'
Error: Command failed (1)**
I've tried installing libcurl, but am not sure I've unzipped it to the correct folder. (From what I've been able to gather from bits and pieces of other questions about rCurl, it seems having an improper/no installation of libcurl could be a contributing factor?)
Any help would be very much appreciated. I feel like I'm going around in circles.
Ann
Adding the directory "C:/R/packages" to the front of the .libPaths variable will help R find RCurl if it's been installed to a non-standard directory.

Resources