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

From: peter dalgaard <PDalgd_at_gmail.com>
Date: Tue, 12 Apr 2011 18:38:58 +0200

On Apr 12, 2011, at 18:24 , Jeffrey Horner wrote:

> 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.

Semi-intended. % is the comment character in .Rd files, and there is no exception for verbatim code in \examples{} et al. So you need \% when it is not a comment.

>

>> 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
-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes_at_cbs.dk  Priv: PDalgd_at_gmail.com

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Tue 12 Apr 2011 - 16:45:57 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:31:01 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