From jeffrey.horner at gmail.com  Tue Apr 12 18:32:31 2011
From: jeffrey.horner at gmail.com (Jeffrey Horner)
Date: Tue, 12 Apr 2011 11:32:31 -0500
Subject: [Rd] parse_Rd raises error when example section contains a
 quoted percent character
In-Reply-To: <19876.32219.593228.213020@fangorn.hornik.net>
References: <BANLkTikscO28Ey+uJ0+-yL4m5kedBFeHdg@mail.gmail.com>
	<19876.32219.593228.213020@fangorn.hornik.net>
Message-ID: <BANLkTin-u5ZKqtTekTmtQvdbOA93JNBZkA@mail.gmail.com>

Thanks for setting me straight, Kurt.

Problem solved.

Jeff

On Tue, Apr 12, 2011 at 11:29 AM, Kurt Hornik <Kurt.Hornik at wu.ac.at> wrote:
>>>>>> Jeffrey Horner writes:
>
> % is the Rd comment character, and almost always needs to be escaped.
>
> Best
> -k
>
>> 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
>
>



-- 
http://biostat.mc.vanderbilt.edu/JeffreyHorner



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