を、しかし、ここで私は調理最小限の例です:原則として私は、次のコードをできるようにしたいと思います。これを実行するには
library(knitr)
knit("r-report.html")
そして例。 R内の
<HTML>
<HEAD>
<TITLE>Analyzing Diamonds!</TITLE>
</HEAD>
<BODY>
<H1>Diamonds are everywhere!</H1>
<!--begin.rcode echo=FALSE
## Load libraries, but do not show this
library(ggplot2)
library(plyr)
testData <- rnorm(1)
end.rcode-->
This is an analysis of diamonds, load the data.<p>
<!--begin.rcode echo=TRUE, fig.keep="all"
# Load the data
data(diamonds)
# Preview
head(diamonds)
end.rcode-->
Generate a figure, don't show code <p>
<!--begin.rcode echo=FALSE, fig.align="center", dev="png"
# This code is not shown, but figure will output
qplot(diamonds$color, fill=diamonds$color) +
opts(title="A plot title")
end.rcode-->
Show some code, don't output the figure<p>
<!--begin.rcode echo=TRUE, fig.keep="none"
# Show the code for this one, but don't write out the figure
ggplot(diamonds, aes(carat, price, colour=cut)) +
geom_point(aes(alpha=0.9))
end.rcode-->
And the value testData: <!--rinline testData --> inside a text block.
</BODY>
</HTML>
ヒントのおかげで。しかし、この例では、htmlファイルにRコードを埋め込む方法を示していません。私はむしろhtmlファイルを作成し、WITHIN Rにコンテンツを書きたいと思います。stitch()のように、htmlファイルにすべてを書き込むよりも柔軟性を持たせたいと思っています。 –