58 lines
1.4 KiB
Plaintext
58 lines
1.4 KiB
Plaintext
<!DOCTYPE html>
|
|
<html>
|
|
<!--
|
|
%\VignetteEngine{knitr::knitr_notangle}
|
|
%\VignetteIndexEntry{An R HTML Vignette with knitr}
|
|
-->
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<style type="text/css">
|
|
body,td{width:800px;margin:auto;}
|
|
</style>
|
|
<title>An R HTML vignette with knitr</title>
|
|
</head>
|
|
<!--begin.rcode setup, include=FALSE
|
|
library(knitr)
|
|
# to base64 encode images
|
|
opts_knit$set(upload.fun = image_uri)
|
|
end.rcode-->
|
|
|
|
<body>
|
|
|
|
<p>This is an R HTML vignette. The file extension is <code>*.Rhtml</code>, and
|
|
it has to include a special comment to tell R that this file needs to be
|
|
compiled by <strong>knitr</strong>:</p>
|
|
|
|
<pre><!--
|
|
%\VignetteEngine{knitr::knitr}
|
|
%\VignetteIndexEntry{The Title of Your Vignette}
|
|
-->
|
|
</pre>
|
|
|
|
<p>Now you can write R code chunks:</p>
|
|
|
|
<!--begin.rcode cars-demo
|
|
summary(cars)
|
|
fit=lm(dist~speed, data=cars)
|
|
summary(fit)
|
|
end.rcode-->
|
|
|
|
<p>You can also embed plots, for example:</p>
|
|
|
|
<!--begin.rcode cars-plot, fig.width=7, fig.height=6, fig.align='center'
|
|
par(mar=c(4,4,.1,.1))
|
|
plot(cars, pch=19)
|
|
end.rcode-->
|
|
|
|
<p>For package vignettes, you need to encode images in base64 strings using the
|
|
<code>knitr::image_uri()</code> function so that the image files are no longer
|
|
needed after the vignette is compiled. For example, you can add this chunk in
|
|
the beginning of a vignette:</p>
|
|
|
|
<!--begin.rcode setup, eval=FALSE
|
|
end.rcode-->
|
|
|
|
</body>
|
|
</html>
|