Hi, I have spent a few hours on the R-exts manual and the documentation of parse_Rd() (as well as the PDF document in the references), but I still have not figured out what results=rd means. I thought I could use an R code fragment to create an Rd fragment dynamically. Here is an example, in which I was expected the output to be a describe list <DL> in HTML, but it turns out not to be true. (I was actually building a package with Rd's containing \Sexpr{} instead of really using Rd2HTML(); the content was not rendered after I run R CMD build.) des <- "\\describe{\\item{def}{ghi}}" con <- textConnection(c("\\title{abc}\\name{abc}", "\\details{\\Sexpr[results=rd,stage=build]{des}}")) z <- parse_Rd(con) Rd2HTML(z, stages = "build") close(con) <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><title>R: abc</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" type="text/css" href="R.css"> </head><body> <table width="100%" summary="page for abc"><tr><td>abc</td><td align="right">R Documentation</td></tr></table> <h2>abc</h2> <h3>Details</h3> <p>defghi</p> </body></html>> sessionInfo()R version 2.13.2 (2011-09-30) Platform: x86_64-pc-linux-gnu (64-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 utils datasets methods [8] base other attached packages: [1] devtools_0.4 loaded via a namespace (and not attached): [1] RCurl_1.6-10 Thanks! Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Phone: 515-294-2465 Web: http://yihui.name Department of Statistics, Iowa State University 2215 Snedecor Hall, Ames, IA
Gavin Simpson
2011-Oct-17 13:45 UTC
[R] What does \Sexpr[results=rd]{} exactly mean in Rd?
On Sun, 2011-10-16 at 19:36 -0500, Yihui Xie wrote:> Hi, > > I have spent a few hours on the R-exts manual and the documentation of > parse_Rd() (as well as the PDF document in the references), but I > still have not figured out what results=rd means. I thought I could > use an R code fragment to create an Rd fragment dynamically. Here is > an example, in which I was expected the output to be a describe list > <DL> in HTML, but it turns out not to be true.Perhaps best not to cross post to several internet resources at once. I replied to the same Q on StackOverflow: http://stackoverflow.com/q/7788628/429846 Suffice it to say that your example works for me with 2.13.1 (still need to compile 2.13.2 on my workstation). I left some additional comments and examples, which might help understand this. I had trouble when I first started playing this and didn't pursue further, but I think I am starting to understand how to use this now after taking a look when I tried to answer your Q. G> (I was actually building a package with Rd's containing \Sexpr{} > instead of really using Rd2HTML(); the content was not rendered after > I run R CMD build.) > > des <- "\\describe{\\item{def}{ghi}}" > con <- textConnection(c("\\title{abc}\\name{abc}", > "\\details{\\Sexpr[results=rd,stage=build]{des}}")) > z <- parse_Rd(con) > Rd2HTML(z, stages = "build") > close(con) > > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> > <html><head><title>R: abc</title> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> > <link rel="stylesheet" type="text/css" href="R.css"> > </head><body> > > <table width="100%" summary="page for abc"><tr><td>abc</td><td > align="right">R Documentation</td></tr></table> > > <h2>abc</h2> > > <h3>Details</h3> > > <p>defghi</p> > > > </body></html> > > > > sessionInfo() > R version 2.13.2 (2011-09-30) > Platform: x86_64-pc-linux-gnu (64-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 utils datasets methods > [8] base > > other attached packages: > [1] devtools_0.4 > > loaded via a namespace (and not attached): > [1] RCurl_1.6-10 > > > Thanks! > > Regards, > Yihui > -- > Yihui Xie <xieyihui at gmail.com> > Phone: 515-294-2465 Web: http://yihui.name > Department of Statistics, Iowa State University > 2215 Snedecor Hall, Ames, IA > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%