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),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With