Compile R package "arulesSequence" for older release - r

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.

Related

Installing R package ERROR: installing binary package failed

Complete newbie here, so there is probably something glaringly bad here. I created a Project following Hadley Wickham's book on R packages, and now I am trying add it to github for remote install (repository for reference).
Running devtools::install_github("alutterb/abcmlr") generated the following output:
Downloading GitHub repo alutterb/abcmlr#master
√ checking for file 'C:\Users\amlut\AppData\Local\Temp\RtmpMpn5uJ\remotes7146c405dd7\alutterb-abcmlr-918bf05/DESCRIPTION' ...
- preparing 'abcmlr':
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'abcmlr_0.1.0.tar.gz'
Installing package into ‘C:/Users/amlut/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
* installing *binary* package 'abcmlr' ...
cp: unknown option -- )
Try '/Rtools/bin/cp --help' for more information.
ERROR: installing binary package failed
* removing 'C:/Users/amlut/Documents/R/win-library/3.5/abcmlr'
In R CMD INSTALL
Error in i.p(...) :
(converted from warning) installation of package ‘C:/Users/amlut/AppData/Local/Temp/RtmpMpn5uJ/file71463953e7b/abcmlr_0.1.0.tar.gz’ had non-zero exit status
In my repository, I have a Linux executable that is to be used with wsl as well as an .exe file that is called in my R code. These may be the culprits, but I am not entirely sure. The error states that it failed to install the binary package, but install_github() takes a source package, so I am not sure what is going on. Any help is appreciated.
Thank you.
EDIT: This problem is solved. It was because of a line in my DESCRIPTION file that had to do with Built.
Check your %PATH% and type: where cp.
Another cp (like one from the Git for Windows distribution) might overshadow the RTools cp, which might explain the error message.
As commented by the OP hkj447, the error was trigger by a line in the DESCRIPTION file:
Built: R 3.5.3; ; 2019-06-14 21:17:43 UTC; windows
As seen in this thread:
You have a field called 'Built:' in your package's DESCRIPTION file;
R normally tries to inject that field itself when it builds your package from sources.
I deleted "Built"'s line in DESCRIPTION and then installed again.
This time, no error appeared.

Error in in installing an old version of a R package

I tryed to install from file an old version of RgoogleMaps package with this command
install.packages("F://RgoogleMaps_1.1.9.15.tar.gz", repos = NULL, type="source")
but i found this error message:
* installing *source* package 'RgoogleMaps' ...
** package 'RgoogleMaps' successfully unpacked and MD5 sums checked
ERROR: a 'NAMESPACE' file is required
* removing 'C:/Users/Famiglia Mazza/Documents/R/win-library/3.1/RgoogleMaps'
* restoring previous 'C:/Users/Famiglia Mazza/Documents/R/win-library/3.1/RgoogleMaps'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-31~1.2/bin/x64/R" CMD INSTALL -l "C:\Users\Famiglia Mazza\Documents\R\win-library\3.1" "F://RgoogleMaps_1.1.9.15.tar.gz"' had status 1
Warning in install.packages :
installation of package ‘F://RgoogleMaps_1.1.9.15.tar.gz’ had non-zero exit status
what can I do? I'm using R on Windows
In R 2.14.0 a requirement was made that all packages had namespaces, but as a transitional arrangement those that didn't would have one automatically generated at install time.
A package R code but without a ‘NAMESPACE’ file will have a default
one created at R CMD build or R CMD INSTALL time, so all packages will
be installed with namespaces. A consequence of this is that
.First.lib() functions need to be copied to .onLoad() (usually) or
.onAttach(). For the time being, if there is an auto-generated
‘NAMESPACE’ file and no .onLoad() nor .onAttach() function is found
but .First.lib() is, it will be run as the attach hook (unless the
package is one of a list of known exceptions, when it will be run as
the load hook).
However, by R 3.0.0 this transitional arrangement was ended:
The transitional support for installing packages without namespaces
(required since R 2.14.0) has been removed. R CMD build will still add
a namespace, but a .First.lib() function will need to be converted.
R CMD INSTALL no longer adds a namespace (so installation will fail),
and a .First.lib() function in a package will be ignored (with an
installation warning for now).
As an exception, packages without a ‘R’ directory and no ‘NAMESPACE’
file can still be installed.
Therefore, I suggest you use an older version of R to run this package. One prior to R 3.0.0 should suffice, and the latest one prior to that is R 2.15.3.

Install package from source throws "package not available" in R

I've read many posts here on how to install R packages from local files, from source etc. and still I have troubles installing (my own) package. The package was created using RStudio, Roxygen2 and RTools (Windows).
The package I'm trying to install (I do this in order to give an instruction so other people know how to install the package - I myself just compile and install the package from RStudio) can be downloaded here:
sjPlot-package
I also created a PACKAGE description, that is located on my server in the same directory as the package, using write_PACKAGES().
Now, if I try install.packages("sjPlot_0.1", contrib.url="http://www.strengejacke.de/R-Stuff/sjPlot/") I get following error message:
Warning in install.packages :
package ‘sjPlot_0.1’ is not available (for R version 3.0.2)
If I use install.packages("sjPlot_0.1", repos="http://www.strengejacke.de/R-Stuff/sjPlot/") I get following error message:
source repository is unavailable to check versions
Error in install.packages : Line starting ' ...' is malformed!
Also, a local install via install.packages("sjPlot_0.1", contriburl="C:/Users/Luedeke/Dropbox/R-Statistics/packages/") fails (this directory contains source-package, binary-package and PACKAGE descr. files).
I know there are a lot of postings on how to install R packages, and I read some of them - perhaps I missed the right one, if so, please excuse me for asking this question again.
My question is: How can I (or other people) install my R package (including installation of dependencies would be nice)?
Thanks in advance
Daniel
Your package does not pass R CMD check:
> R CMD check sjPlot_0.1.tar.gz
* using log directory ‘/home/edisz/Downloads/sj_tmp/sjPlot.Rcheck’
* using R version 3.0.2 (2013-09-25)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘sjPlot/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘sjPlot’ version ‘0.1’
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Namespace dependencies not required:
‘HH’ ‘MASS’ ‘car’ ‘faraway’ ‘foreign’ ‘ggplot2’ ‘lmtest’ ‘plyr’
‘reshape2’ ‘scales’ ‘vcd’
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.
Exited with status 1.
Looking at your DESCRIPTION file, you'll see that the Collate and Import fields are missing.
Roxygen take care of the Collate fields (If you're using RStudio Configure roxygen to do so), however you have to write the Import field manually to the DESCRIPTION.
Looking at one of your functions:
#' #title Import SPSS dataset as data frame into R
[snip]
#'
#' #param path the file path to the SPSS dataset
#' #param enc the file encoding of the SPSS dataset
#' #return a data frame containing the SPSS data. retrieve value labels with \code{\link{sji.getValueLabels}}
#' and variable labels with \code{\link{sji.getVariableLabels}}
[snip]
#' #export
sji.SPSS <- function(path, enc=NA) {
# init foreign package
require("foreign")
# import data as data frame
data.spss <- read.spss(path, to.data.frame=TRUE, use.value.labels=FALSE, reencode=enc)
# return data frame
return(data.spss)
}
You see that there is a require('foreign') call, but no #import foreign tag.
I would suggest to remove the line require('foreign') (it's not needed, if you import the package) and add a #import foreign tag.
Than add to your Description file
Imports:
foreign
Do this with all other functions and packages.
Hope this helps (and is correct),

RStudio * checking package dependencies ... ERROR

this has now been bugging me for a while now and I can't make other related pieces of advice fit to my problem. Yes, i have perused the net for help.
Problemstatement:
I have written a package with all the basic requirements to make a first build.
However, I have two dependecies (functions from other packages) which seemingly can't be loaded.
==> Rcmd.exe build mypackage
[...]
* using log directory 'mydirectory/mypackage.Rcheck'
* using R version 2.15.2 (2012-10-26)
* using platform: x86_64-w64-mingw32 (64-bit)
* using session charset: ISO8859-1
* checking for file 'mypackagel/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'mypackage' version '0.01'
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package required but not available: 'otherpackage'
Exited with status 1.
Now I am using RStudio to do the package building. However, it seems I cannot make it find the 'otherpackage'. Where do I set this under Windows/RStudio?
Anyone can give a quick hint, please?

Error in R CMD Check: Packages required but not available

I am trying to create a package. It depends on several packages. I added the imports to the namespace file and the Depends in the description file.
I found possible solutions here and here, but these didn't work- I think because I am on CentOS.
This is what I see on my screen:
[hadoop#localhost RProjects]$ sudo R CMD check TextPreProcess
* using log directory ‘/home/hadoop/RProjects/TextPreProcess.Rcheck’
* using R version 2.15.1 (2012-06-22)
* using platform: x86_64-redhat-linux-gnu (64-bit)
* using session charset: UTF-8
* checking for file ‘TextPreProcess/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘TextPreProcess’ version ‘1.0’
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Packages required but not available:
‘RWeka’ ‘Snowball’ ‘lsa’ ‘plyr’ ‘snowfall’ ‘tau’ ‘tm’
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.
I went through Writing R Extentions but I couldn't derive a lot of insight as to how to solve my problem.
It's working now.
What I did was:
add ~/R/x86_64-redhat-linux-gnu-library/2.15 to .libPaths (That's where my R library was)
Detach all libraries in R
Restart the R session. (For multiple sessions, close all of them.)
install the required packages.
Check if the Imports & Exports are correct in the namespace file.
Check if the required fields are available in the Description file. Make sure all dependencies are handled between 'Depends', 'Imports', 'Suggests' and 'Enhances'.
Checked it. R CMD check <pkg>. Built it. R CMD build <pkg>. Installed it. R CMD INSTALL <tarball>.
Done.
I had the same problem because packages were installed but for different R versions.
To solve, I opened the old R version (the one the package was built under), and installed the missing packages under that version and it solved the problem.
E.g.
# Version should match the version your package was built in
R.version
# 3.5.1
install.packages(c('stringr', 'lubridate', 'testthat'))
Tips
If you need to check your R version, simply type R.version
If you need to switch R version, hold control while starting RStudio on windows, or on mac download a very simple application called RSwitch to instantly switch between version (you'll still need to restart the R session with .rs.restartR()

Resources