[R] What does \Sexpr[results=rd]{} exactly mean in Rd?

Yihui Xie xie at yihui.name
Mon Oct 17 02:36:24 CEST 2011


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



More information about the R-help mailing list