[Rd] parse_Rd raises error when example section contains a quoted percent character

From: Jeffrey Horner <jeffrey.horner_at_gmail.com>
Date: Tue, 12 Apr 2011 11:24:10 -0500


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

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 12 Apr 2011 - 16:27:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Apr 2011 - 23:10:46 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive