I having the following issue when trying to check a package using the command line.
First I get this very general error message:
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
* checking PDF version of manual without hyperrefs or index … ERROR
Then, when I check Rdlatex log, I found the following complain:
Transcript written on Rd2.log.
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet, :
unable to run 'pdflatex' on 'Rd2.tex'
Error in running tools::texi2pdf()
You may want to clean up by 'rm -rf /var/folders/_q/_kj9kz0n0qq_gwkrv9qjvpxw0000gn/T//Rtmp7uzkmZ/Rd2pdf2a847787e63'
For some reason it didn't manage to run pdflatex though it is properly installed as the following testifies. Does anyone has a clue on how I can fix it?
system("pdflatex --version")
pdfTeX 3.14159265-2.6-1.40.15 (TeX Live 2014)
kpathsea version 6.2.0
Copyright 2014 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.6.10; using libpng 1.6.10
Compiled with zlib 1.2.8; using zlib 1.2.8
Compiled with xpdf version 3.03
Very weirdly, running R CMD Rd2pdf man/ produces output.
LaTeX Font Warning: Some font shapes were not available, defaults substituted.
)
(see the transcript file for additional information){/usr/local/texlive/2014bas
ic/texmf-dist/fonts/enc/dvips/inconsolata/i4-ts1.enc}{/usr/local/texlive/2014ba
sic/texmf-dist/fonts/enc/dvips/base/8r.enc}{/usr/local/texlive/2014basic/texmf-
dist/fonts/enc/dvips/inconsolata/i4-t1-0.enc}</usr/local/texlive/2014basic/texm
f-dist/fonts/type1/public/inconsolata/Inconsolata-zi4r.pfb></usr/local/texlive/
2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/local/texl
ive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/local/
texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi7.pfb></usr/loc
al/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb></usr/
local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr5.pfb></us
r/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb></
usr/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pf
b></usr/local/texlive/2014basic/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7
.pfb></usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/helvetic/uhvr8a.p
fb></usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmb8a.pfb></
usr/local/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/l
ocal/texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmr8a.pfb></usr/local/
texlive/2014basic/texmf-dist/fonts/type1/urw/times/utmri8a.pfb>
Output written on Rd2.pdf (62 pages, 264746 bytes).
Transcript written on Rd2.log.
Saving output to 'Rd2.pdf' ...
Done
I had R CMD check and R CMD Rd2pdf fail because one of our collabs created an empty curly-braces block that was not escaped by roxygen and broke the laTeX render, .i.e. the \dontrun{} below :
#' An example of breaking the R CMD Rd2pdf with unescaped curly braces.
#'
#' #param df A dataframe.
#' #return A dataframe.
#'
#' #examples
#' \dontrun{
#' }
#' #export
funcname <- function(df){
df
}
Related
I coded an R package that is hosted on my GitHub. I included a vignette, and I can install the package and load the vignette without any issue from R and RStudio by doing:
devtools::install_github("rosalieb/serac", build_vignettes = TRUE)
library(serac)
vignette("serac")
However, I have a few colleagues who cannot install the vignette (the only way they can download the package is by doing devtools::install_github("rosalieb/serac") (default of build_vignettes is FALSE).
It works if they use RStudio, but not in 'regular' R.
I encourage people to use RStudio, but I cannot force them, and eventually, I do not understand why it would work in 'regular' R for me but not for them.
They tried to install pandoc, knitr, Rtools - none of these worked.
Here is the error message when my colleague tries to install the package with the vignette:
v checking for file 'C:\Temp\RtmpO8YwVb\remotesf9842f1431\rosalieb-serac-46a3587/DESCRIPTION'
- preparing 'serac':
checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
v checking DESCRIPTION meta-information
- installing the package to build vignettes
creating vignettes ...
creating vignettes ...
E creating vignettes (4.9s)
--- re-building 'serac.Rmd' using rmarkdown
Error: processing vignette 'serac.Rmd' failed with diagnostics:
Pandoc is required to build R Markdown vignettes but not available. Please make sure it is installed.
--- failed re-building 'serac.Rmd'
RESUME : le traitement du fichier suivant a échoué :
'serac.Rmd'
Erreur : Vignette re-building failed.
Exécution arrêtée
Erreur : Failed to install 'serac' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout & stderr were printed
Thanks in advance for your help!
The message indicates that rmarkdown::render can't find Pandoc.
It looks for it in three places: in the directory specified by the RSTUDIO_PANDOC environment variable, in directories on the PATH, in the directory opt/pandoc in the user's home directory. So your colleagues who have installed it should make sure it is available in one of those locations. They can see the current values of the environment variables by running
Sys.getenv("PATH")
and
Sys.getenv("RSTUDIO_PANDOC")
Temporary changes can be made using
Sys.setenv(RSTUDIO_PANDOC="/path/to/pandoc/directory")
This needs to happen in the session that is trying to install the package and build the vignette, not in the vignette itself.
How to make permanent changes to those values depends on the details of what system they are running.
I've been writing a lot of code for my personal use and finally reached a point where I realised I should really be including this all in a package which I can load in instead of copy and pasting it in each time.
I followed the following tutorial for the creation of a basic package.
https://hilaryparker.com/2014/04/29/writing-an-r-package-from-scratch/
As far as I can tell everything went well with the actual creation element. Here are screenshots of the result:
The cats folder:
The /cats/R folder
The /cats/man folder
The problem comes when I want to run the line:
install("cats")
When I try to do that I get the following error:
Installing cats
"C:/PROGRA~1/R/R-33~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL "/Documents/cats" --library="C:/Users/Aodhán/Documents/R/win-library/3.3" --install-tests
* installing *source* package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats/DESCRIPTION': No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
* removing 'C:/Users/Aodhán/Documents/R/win-library/3.3/cats'
Error: Command failed (1)
This error happens for my own package, but it also happens if I run the command:
devtools::install_github("klutometis/roxygen")
Any advice would be appreciated.
EDIT: Could it be that my username contains the character á in it?
EDIT 2:The DESCRIPTION file is:
Package: cats
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors#R: person("First", "Last", email = "first.last#example.com",
role = c("aut", "cre"))
Maintainer: Aodhán O'Leary
Author: Aodhán O'Leary [aut, cre]
Description: What the package does (one paragraph).
Depends: R (>= 3.3.1)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
Sys.getenv("R_HOME") returns "C:/PROGRA~1/R/R-33~1.1"
Sys.getenv("R_LIBS_USER") returns "C:\Users\Aodhán\Documents/R/win-library/3.3"
Sys.getenv("R_HOME") returns "C:\Users\Aodhán\Documents"
devtools::build("cats") creates "cats_0.0.0.9000.tar.gz"
install.packages("../cats_version.tar.gz") returns the same error as above
Note: This is on a Win10 machine, using R 3.3.1, which I apologise for not mentioning up top. I was quite tired when writing the post yesterday.
Edit 3: Here's the result of using the following commands: R CMD build cats followed by R CMD check cats
00check:
using log directory 'C:/Users/Aodhán/Documents/cats.Rcheck'
using R version 3.3.1 (2016-06-21)
using platform: x86_64-w64-mingw32 (64-bit)
using session charset: ISO8859-1
checking for file 'cats/DESCRIPTION' ... OK
this is package 'cats' version '0.0.0.9000'
package encoding: UTF-8
checking package namespace information ... OK
checking package dependencies ... OK
checking if this is a source package ... OK
checking if there is a namespace ... OK
checking for .dll and .exe files ... OK
checking for hidden files and directories ... NOTE Found the following hidden files and directories: .gitignore These were most
likely included in error. See section 'Package structure' in the
'Writing R Extensions' manual.
checking for portable file names ... OK
checking whether package 'cats' can be installed ... ERROR Installation failed. See
'C:/Users/Aodhán/Documents/cats.Rcheck/00install.out' for details.
DONE
Status: 1 ERROR, 1 NOTE
00install.out
installing source package 'cats' ...
Warning in file(file, if (append) "a" else "w") :
cannot open file 'C:/Users/Aodhan/Documents/cats.Rcheck/cats/DESCRIPTION':
No such file or directory
Error in file(file, if (append) "a" else "w") :
cannot open the connection
ERROR: installing package DESCRIPTION failed for package 'cats'
removing 'C:/Users/Aodhán/Documents/cats.Rcheck/cats'
The problem was the special character in my name, á. When I put it in the C:\ directory and ran R CMD build cats and R CMD check cats it passed that error (though there was an error later on with the pdf - I'll see if I can resolve that myself).
I'll try and post this as a bug. Moderately annoying. Should have thought of that test earlier.
I've run into this problem recently (R version 3.5.2) on two different computers. I don't have the full, exact error message right now, but it contained the following two snippets:
Error in writeLines(paste0(c(out[is_not_empty]), eor), file, useBytes = useBytes) :
(converted from warning) invalid char string in output conversion
and
ERROR: installing package DESCRIPTION failed for package
The problem, I believe, was the existence of special characters in my .Rprofile file. I'd been meaning to get rid of that file anyway (for the sake of reproducibility), and doing so fixed the problem.
To do this in R, the code below will (1) copy your .Rprofile and save it as .Rprofile-old (in case you want to use/restore it later on) and then (2) delete your .Rprofile.
## copy backup of .Rprofile
file.copy("~/.Rprofile", "~/.Rprofile-old")
## delete .Rprofile
unlink("~/.Rprofile")
Once you've run the above code, restart R and the problem will [hopefully] be fixed!
Installing source package..
It is important to specify repo and type
Convert package into package_name.tar.gz
Get into project environment by double clicking the .Rproj file in
your project and click on build -> Build Source Package to build tar.gz file
install.packages("full_path/package_name.tar.gz", repo = NULL, type =
"source")
I wish to include a static PDF file in vignette of my R package biglasso. I followed the instruction here and here. However when I run R CMD check, there is always a NOTE saying:
Vignette sources in 'inst/doc' with no 'vignettes' directory:
'biglasso.pdf.asis'
A 'vignettes' directory is required as from R 3.1.0
and
* checking for old-style vignette sources ... NOTE
Vignette sources only in 'inst/doc':
'biglasso.pdf.asis'
A 'vignettes' directory is required as from R 3.1.0
and these will not be indexed nor checked
Here is the complete package check information.
Could anyone explain to me what this note means and how to fix it?
I'm using knitr to build an R package vignette. This process worked before R 3.0, but I haven't been able to rebuild the package under R 3.1.1.
When I try R CMD build I get an error message:
R CMD build Causata
* checking for file ‘Causata/DESCRIPTION’ ... OK
* preparing ‘Causata’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
* creating vignettes ...
ERROR Error in loadVignetteBuilder(vigns$pkgdir) :
vignette builder 'knitr' not found Calls: <Anonymous> -> loadVignetteBuilder
In addition:
Warning message: In tools::buildVignettes(dir = ".", tangle = TRUE) :
Files named as vignettes but with no recognized vignette engine:
‘vignettes/Causata-vignette.rnw’ (Is a VignetteBuilder field missing?)
Execution halted
My vignette file has a VignetteEngine call -- here are the first three lines:
% !Rnw weave = knitr
%\VignetteEngine{knitr::knitr}
%\VignetteIndexEntry{Model training and export}
My package description file includes a VignetteBuilder field:
VignetteBuilder: knitr
I think I'm following the instructions for Rnw vignettes, so I'm baffled by the error message I'm seeing.
Incidentally, if I try to build the vignette directly then everything seems to work perfectly. This command generates the vignette PDF:
tools::buildVignettes(dir=".", tangle=TRUE)
My trouble seems to be only with R CMD build. Why won't the build work?
Here's my complete package DESCRIPTION file for reference:
Package: Causata
Type: Package
Title: Analysis utilities for binary classification and Causata users.
Version: 5.0-1
Date: 2014-10-09
Author: Justin Hemann, David Barker, Suzanne Weller, Jason McFall
Maintainer: Justin Hemann <justin.hemann#nice.com>
Description: The Causata package provides utilities for
extracting data from the Causata application, training regression / classification
models, and exporting models as PMML for scoring.
Depends: R (>= 2.15.1)
Imports: XML, R.utils, rjson, RCurl, stringr, yaml, boot, foreach, data.table, glmnet, ggplot2, methods
Suggests: knitr, doMC, testthat, pROC, RODBC, RMySQL
VignetteBuilder: knitr
License: GPL
LazyLoad: yes
URL: www.nice.com
According to the feedback of Josh O'Brien, I guess you might have the same issue as him. If you want to add some custom library paths, I'd recommend you to do it in ~/.Renviron using the environment variable R_LIBS_USER, instead of defining the library paths in ~/.Rprofile or Rprofile.site. The latter seems to be ignored by R CMD build and R CMD check.
Or you can add Sys.setenv(R_LIBS_USER="/my/r-package/dir/") to ~/.Rprofile.
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),