Dear R-Group,
I have a function that sorts a data frame and oneo of the lines in the
function is:
vars <- unlist(strsplit(formc, "[\\+\\-]"))
The function works fine and the above line is always reached. However, when I
include the function in a package and run "R CMD check pkgname" it gives this
error message:
'\+' is an unrecognized escape in character string starting "[\+"
Execution halted
I am running Win 7, R-2.13.1 and run R CMD ... from a command line, using
shell ("start cmd").
I didn't write the function but it has always run fine without any errors.
Is there a way to resolve this so it will pass the package check?
Thank you.
Jeff
R CMD check
6 messages · Duncan Murdoch, Jeff Breiwick, Richard M. Heiberger +1 more
On 05/10/2011 4:46 PM, Jeff Breiwick wrote:
Dear R-Group,
I have a function that sorts a data frame and oneo of the lines in the
function is:
vars<- unlist(strsplit(formc, "[\\+\\-]"))
The function works fine and the above line is always reached. However, when I
include the function in a package and run "R CMD check pkgname" it gives this
error message:
'\+' is an unrecognized escape in character string starting "[\+"
Execution halted
I am running Win 7, R-2.13.1 and run R CMD ... from a command line, using
shell ("start cmd").
I didn't write the function but it has always run fine without any errors.
Is there a way to resolve this so it will pass the package check?
That looks strange. Can you put your package source online somewhere so we could try it? Duncan Murdoch
Jeff Breiwick <jeff.breiwick <at> noaa.gov> writes:
Dear R-Group, I have a function that sorts a data frame and oneo of the lines in the function is: vars <- unlist(strsplit(formc, "[\\+\\-]")) The function works fine and the above line is always reached. However, when
I
include the function in a package and run "R CMD check pkgname" it gives
this
error message:
'\+' is an unrecognized escape in character string starting "[\+"
Execution halted
I am running Win 7, R-2.13.1 and run R CMD ... from a command line, using
shell ("start cmd").
I didn't write the function but it has always run fine without any errors.
Is there a way to resolve this so it will pass the package check?
Thank you.
Jeff
To test 'R CMC check' I created a test package with only this one function in
it. After running package.skeleton() the only thing I did was to edit
DESCRIPTION, test-package.Rd and sort.data.frame.Rd. The offending line is 13:
sort.data.frame <- function (x, by)
{
# From R Help list, by Kevin Wright, Sept. 2004
# Sorts data.frame by columns, either ascending or descending
# e.g. sort.data.frame(x, by = ~ year + fishery + area)
##############################################################
if (by[[1]] != "~")
stop("Argument 'by' must be a one-sided formula.")
formc <- as.character(by[2])
formc <- gsub(" ", "", formc)
if (!is.element(substring(formc, 1, 1), c("+", "-")))
formc <- paste("+", formc, sep = "")
vars <- unlist(strsplit(formc, "[\\+\\-]"))
vars <- vars[vars != ""]
calllist <- list()
pos <- 1
for (i in 1:length(vars)) {
varsign <- substring(formc, pos, pos)
pos <- pos + 1 + nchar(vars[i])
if (is.factor(x[, vars[i]])) {
if (varsign == "-") {
calllist[[i]] <- -rank(x[, vars[i]])
}
else {
calllist[[i]] <- rank(x[, vars[i]])
}
}
else {
if (varsign == "-") {
calllist[[i]] <- -x[, vars[i]]
}
else {
calllist[[i]] <- x[, vars[i]]
}
}
}
return(x[do.call("order", calllist), ])
}
-Jeff
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111005/8a808f46/attachment.pl>
Richard M. Heiberger <rmh <at> temple.edu> writes:
The next thing to check is this item from doc/manual/R-exts.html
Quoted strings within R-like text are handled specially...
My guess is that the problem is occuring in the .Rd file, not in the .R
file.
Remove the line, or double the "\" characters.
Rich
Yes, the error appears to be in the .Rd file so I will modify that. Thanks. Jeff
On 05.10.2011 23:56, Jeff Breiwick wrote:
Richard M. Heiberger<rmh<at> temple.edu> writes:
The next thing to check is this item from doc/manual/R-exts.html
Quoted strings within R-like text are handled specially...
My guess is that the problem is occuring in the .Rd file, not in the .R
file.
Remove the line, or double the "\" characters.
Rich
Yes, the error appears to be in the .Rd file so I will modify that. Thanks.
Then you have not deleted the function from its example section where backslashes have to be escaped once more. Uwe Ligges
Jeff
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.