[Rd] parse_Rd raises error when example section contains a quoted percent character
Jeffrey Horner
jeffrey.horner at gmail.com
Tue Apr 12 18:24:10 CEST 2011
I was writing Rd documentation for a new package when I came across
this issue. Here's the smallest example:
> library(tools)
> cat("\\examples{x <- '<%=rnorm(1)%>'}\n",file=file.path(tempdir(),'test.Rd'))
> readLines(file.path(tempdir(),'test.Rd'))
[1] "\\examples{x <- '<%=rnorm(1)%>'}"
> parse_Rd(file.path(tempdir(),'test.Rd'))
Error in parse_Rd(file.path(tempdir(), "test.Rd")) :
Unexpected end of input (in ' quoted string opened at test.Rd:1:17)
In addition: Warning message:
In parse_Rd(file.path(tempdir(), "test.Rd")) :
newline within quoted string at test.Rd:1
If I take out the percent characters, parse_Rd succeeds:
> cat("\\examples{x <- '<=rnorm(1)>'}\n",file=file.path(tempdir(),'test.Rd'))
> parse_Rd(file.path(tempdir(),'test.Rd'))
\examples{x <- '<=rnorm(1)>'}
So is this intended behavior or a bug? I would like to use the percent
sign in a quoted string as it is part of brew syntax, and I'm writing
example code to demonstrate such.
> sessionInfo()
R version 2.13.0 RC (2011-04-12 r55422)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] tools stats graphics grDevices datasets utils methods
[8] base
Jeff
--
http://biostat.mc.vanderbilt.edu/JeffreyHorner
More information about the R-devel
mailing list