I am a latex newbee. I properly installed MikTeX 2.9, GhostScript, GSView, TeXnicCenter, and made the settings properly.
My package (named "mypackage") passed package check
via
From R console: devtools::check("C:/Users/User/Documents/Revolution/mypackage")
From DOS command prompt: R CMD check mypackage
without any problem, and I obtained mypackage.PDF files automatically eventually.
I decided to produce mathematical expressions, e.g.,
in the resultant .PDF file. So, I added the following latex expressions in the line in .R file:
#' @param max selected ...The default is Schwert's approximation: \eqn{\lfloor 12(length(t) \over 100)^{\sfrac{1}{4}} \rfloor}
I roxygenized and triggered the above package-checks once more. This time, in the package check, I get the following error (in Command Prompt):
* checking PDF version of manual ...Warning: running command '"C:/Revolution/R-Enterprise-7.3/R-3.1.1/bin/x64/Rcmd.exe" Rd2pdf --batch --no-preview --build-dir
="C:/Users/User/AppData/Local/Temp/RtmpysnRGn/Rd2pdf1b3050f426ea" --no-clean -o mypackage-manual.pdf
"C:/Users/User/Documents/Revolution/mypackage.Rcheck/mypackage"' had status 1
WARNING LaTeX errors when creating PDF version. This typically indicates Rd problems. LaTeX errors found: ! Undefined control sequence.
<argument> ...oor 12(length(t) \over 100)^{\sfrac
{1}{4}} \rfloor
l.67 ...th(t) \over 100)^{\sfrac{1}{4}} \rfloor}{}
checking PDF version of manual without hyperrefs or index ...Warning: running command '"C:/Revolution/R-Enterprise-7.3/R-3.1.1/bin/x64/Rcmd.exe" Rd2pdf --bat
ch --no-preview --build-dir="C:/Users/User/AppData/Local/Temp/RtmpysnRGn/Rd2pdf1b3069b07b94" --no-clean --no-index -o mypackage-manual.pdf
C:/Users/User/Documents/Revolution/mypackage.Rcheck/mypackage' had status 1 ERROR
What I did: I analyzed the similar error in SOF, but could not figure out what is going wrong. I am not sure from where the error occured: my latex syntax or something in R.
I would greatly appreciate any help.
Edit (Complete preamble upon Werner's remark; after the below solution is imposed):
#' adfcs
#'
#' Augmented Dickey-Fuller test that uses common (sub-)sample for all of the lags when a selected max order is given to find optimal minimal lag order of the autoregressive process.
#'
#' Augmented Dickey-Fuller test (for unit root testing) that uses common (sub-)sample for all of the lags when a selected max order is given to find optimal minimal lag order of the autoregressive process.
#' The test is based on J.G. McKinnons' numerical distribution functions.
#' MacKinnon, J.G. (1996); Numerical distribution functions for unit root and cointegration tests, J of Applied Econometrics 11, p. 601 618.
#' The default value of max is Schwert's approximation (Schwert, G.W. (1989). Tests for Unit-Roots: A Monte Carlo investigation. Journal of Business and Economic Statistics 7, 147-159.)
#' Usage: adfcs(t, max = floor(12*(length(t)/100)^(1/4)), type = c("c")). I thank Fabian Scheipl, Dept. of Statistics, LMU Munich for his helpful suggestions during the construction of adfcs.
#' When data frame is supplied for the parameter t, specify the column of the variable for which the ADF test is wanted .
#'
#' @param t a numeric vector or time series object whose stationarity is examined
#' @param max selected max lag order to find optimal minimal lag order for the autoregressive process in ADF test. The default is Schwert's approximation: \eqn{\left\|12\left(\frac{length(t)}{100}\right)^{1/4}\right\|}
#' @param type a character string describing the type of the unit root regression. Valid choices are "nc" for a regression with no intercept (constant) nor time trend, and "c" for a regression with an intercept (constant) but no time trend, "ct" for a regression with an intercept (constant) and a time trend. The default is "c".
#' @return Augmented Dickey-Fuller test that uses common sample for all of the lags.
#' @author Erdogan Cevher erdogancevher@@gmail.com
#' @seealso \code{\link{VARomlop}}
#' @examples
#' ## ADF test for the 1st variable in granger.df, max length is that of Schwert's approximation (default).
#' # adfcs(granger.df[,1])
#' ## ADF test for the 3rd variable in granger.df, max length is 10.
#' # adfcs(granger.df[,3], 10)
#' @importFrom fUnitRoots unitrootTest
#' @export
adfcs <- function(...
xfrac
package in your preamble in order to use\sfrac
. However, I'd suggest just using1/4
. – Werner#' header-includes: #' - \usepackage{xfrac}
to the .R file to include xfrac package to use \sfrac. I triggeredR CMD check mypackage
. An error appeared:* checking whether package 'mypackage' can be installed ... WARNING Found the following significant warnings: Warning: C:/Users/User/Documents/Revolution/mypackage/man/adfcs.Rd:31: unknown macro '\usepackage'
. It seems I cannot achieve how to include a TeX package to R's preamble. – Erdogan CEVHER#'
tags are required tags for the roxygen2 package. roxygen2 produces .Rd files from .R files automatically (uponroxygenize("mypackage")
). From there, from command prompt, viaR CMD check mypackge
, I obtain the .PDF files automatically (I installed MikTex and TexNicCenter; GScript; GSview as well; all properly set). – Erdogan CEVHER