Special characters in Rd example section will cause errors
I've noticed this as well. I recently had a % in an Rd file that caused me problems.
On Sat, Jun 20, 2009 at 10:18 AM, Yihui Xie<xieyihui at gmail.com> wrote:
Hi (Duncan?),
The other day I noticed some characters will cause errors in R CMD
CHECK because of parse_Rd(), and AFAIK, these chars include '%', '{'
and '}'. For example, note the comments in the example section:
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
\name{testfun}
\Rdversion{1.1}
\alias{testfun}
\title{
A Test
}
\description{
A test
}
\usage{
testfun()
}
\value{
NULL
}
\author{
Yihui Xie
}
\examples{
# special characters in comments
# what if a bracket '{' here?
}
\keyword{ misc }
%~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%
## error occurs
tools:::parse_Rd('testfun.Rd')
Error in tools:::parse_Rd("testfun.Rd") :
?testfun.Rd:23:1: unexpected section header
23: }
24: \keyword
? ?^
If I remove the '{', the Rd file can be parsed successfully. When you
put a code line with "%" in it, there will also be an error, e.g. you
put this in the example section
sprintf("%s", letters[1])
and you'll get
tools:::parse_Rd('testfun.Rd')
Error in tools:::parse_Rd("testfun.Rd") :
?Unexpected end of input (in " quoted string opened at testfun.Rd:23:10)
In addition: Warning message:
In tools:::parse_Rd("testfun.Rd") :
?newline within quoted string at testfun.Rd:24
Rd_parse() will parse the Rd file incorrectly either.
tools:::Rd_parse('testfun.Rd')
$meta $meta$aliases [1] "testfun" $meta$concepts character(0) $meta$keywords [1] "misc" $meta$doc_type character(0) $meta$encoding character(0) $data ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? vals ? ? ? ?tags 1 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? testfun ? ? ? ?name 2 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 1.1 ? Rdversion 3 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\nA Test\n ? ? ? title 4 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\nA test\n description 5 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \ntestfun()\n ? ? ? usage 6 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\nNULL\n ? ? ? value 7 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \nYihui Xie\n ? ? ?author 8 \n# special characters in comments\n# what if ' ? ?examples $rest ? ? ? ? examples "'? or ''\n\n}\n" Here is my session info:
sessionInfo()
R version 2.9.0 (2009-04-17) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States. 1252 attached base packages: [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base
R.version
? ? ? ? ? ? ? _ platform ? ? ? i386-pc-mingw32 arch ? ? ? ? ? i386 os ? ? ? ? ? ? mingw32 system ? ? ? ? i386, mingw32 status major ? ? ? ? ?2 minor ? ? ? ? ?9.0 year ? ? ? ? ? 2009 month ? ? ? ? ?04 day ? ? ? ? ? ?17 svn rev ? ? ? ?48333 language ? ? ? R version.string R version 2.9.0 (2009-04-17) Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel