147 lines
31 KiB
HTML
147 lines
31 KiB
HTML
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<!--
|
||
|
%\VignetteEngine{knitr::knitr_notangle}
|
||
|
%\VignetteIndexEntry{An R HTML Vignette with knitr}
|
||
|
-->
|
||
|
<head>
|
||
|
<style type="text/css">
|
||
|
.inline {
|
||
|
background-color: #f7f7f7;
|
||
|
border:solid 1px #B0B0B0;
|
||
|
}
|
||
|
.error {
|
||
|
font-weight: bold;
|
||
|
color: #FF0000;
|
||
|
}
|
||
|
.warning {
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.message {
|
||
|
font-style: italic;
|
||
|
}
|
||
|
.source, .output, .warning, .error, .message {
|
||
|
padding: 0 1em;
|
||
|
border:solid 1px #F7F7F7;
|
||
|
}
|
||
|
.source {
|
||
|
background-color: #f5f5f5;
|
||
|
}
|
||
|
.left {
|
||
|
text-align: left;
|
||
|
}
|
||
|
.right {
|
||
|
text-align: right;
|
||
|
}
|
||
|
.center {
|
||
|
text-align: center;
|
||
|
}
|
||
|
.hl.num {
|
||
|
color: #AF0F91;
|
||
|
}
|
||
|
.hl.sng {
|
||
|
color: #317ECC;
|
||
|
}
|
||
|
.hl.com {
|
||
|
color: #AD95AF;
|
||
|
font-style: italic;
|
||
|
}
|
||
|
.hl.opt {
|
||
|
color: #000000;
|
||
|
}
|
||
|
.hl.def {
|
||
|
color: #585858;
|
||
|
}
|
||
|
.hl.kwa {
|
||
|
color: #295F94;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
.hl.kwb {
|
||
|
color: #B05A65;
|
||
|
}
|
||
|
.hl.kwc {
|
||
|
color: #55aa55;
|
||
|
}
|
||
|
.hl.kwd {
|
||
|
color: #BC5A65;
|
||
|
font-weight: bold;
|
||
|
}
|
||
|
</style>
|
||
|
<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>
|
||
|
|
||
|
|
||
|
<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>
|
||
|
|
||
|
<div class="chunk" id="cars-demo"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl kwd">summary</span><span class="hl def">(cars)</span>
|
||
|
</pre></div>
|
||
|
<div class="output"><pre class="knitr r">## speed dist
|
||
|
## Min. : 4.0 Min. : 2
|
||
|
## 1st Qu.:12.0 1st Qu.: 26
|
||
|
## Median :15.0 Median : 36
|
||
|
## Mean :15.4 Mean : 43
|
||
|
## 3rd Qu.:19.0 3rd Qu.: 56
|
||
|
## Max. :25.0 Max. :120
|
||
|
</pre></div>
|
||
|
<div class="source"><pre class="knitr r"><span class="hl def">fit</span><span class="hl kwb">=</span><span class="hl kwd">lm</span><span class="hl def">(dist</span><span class="hl opt">~</span><span class="hl def">speed,</span> <span class="hl kwc">data</span><span class="hl def">=cars)</span>
|
||
|
<span class="hl kwd">summary</span><span class="hl def">(fit)</span>
|
||
|
</pre></div>
|
||
|
<div class="output"><pre class="knitr r">##
|
||
|
## Call:
|
||
|
## lm(formula = dist ~ speed, data = cars)
|
||
|
##
|
||
|
## Residuals:
|
||
|
## Min 1Q Median 3Q Max
|
||
|
## -29.07 -9.53 -2.27 9.21 43.20
|
||
|
##
|
||
|
## Coefficients:
|
||
|
## Estimate Std. Error t value Pr(>|t|)
|
||
|
## (Intercept) -17.579 6.758 -2.60 0.012 *
|
||
|
## speed 3.932 0.416 9.46 1.5e-12 ***
|
||
|
## ---
|
||
|
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
|
||
|
##
|
||
|
## Residual standard error: 15.4 on 48 degrees of freedom
|
||
|
## Multiple R-squared: 0.651, Adjusted R-squared: 0.644
|
||
|
## F-statistic: 89.6 on 1 and 48 DF, p-value: 1.49e-12
|
||
|
</pre></div>
|
||
|
</div></div>
|
||
|
|
||
|
<p>You can also embed plots, for example:</p>
|
||
|
|
||
|
<div class="chunk" id="cars-plot"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl kwd">par</span><span class="hl def">(</span><span class="hl kwc">mar</span><span class="hl def">=</span><span class="hl kwd">c</span><span class="hl def">(</span><span class="hl num">4</span><span class="hl def">,</span><span class="hl num">4</span><span class="hl def">,</span><span class="hl num">.1</span><span class="hl def">,</span><span class="hl num">.1</span><span class="hl def">))</span>
|
||
|
<span class="hl kwd">plot</span><span class="hl def">(cars,</span> <span class="hl kwc">pch</span><span class="hl def">=</span><span class="hl num">19</span><span class="hl def">)</span>
|
||
|
</pre></div>
|
||
|
</div><div class="rimage center"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfgAAAGwCAYAAABFI3d+AAAEDmlDQ1BrQ0dDb2xvclNwYWNlR2VuZXJpY1JHQgAAOI2NVV1oHFUUPpu5syskzoPUpqaSDv41lLRsUtGE2uj+ZbNt3CyTbLRBkMns3Z1pJjPj/KRpKT4UQRDBqOCT4P9bwSchaqvtiy2itFCiBIMo+ND6R6HSFwnruTOzu5O4a73L3PnmnO9+595z7t4LkLgsW5beJQIsGq4t5dPis8fmxMQ6dMF90A190C0rjpUqlSYBG+PCv9rt7yDG3tf2t/f/Z+uuUEcBiN2F2Kw4yiLiZQD+FcWyXYAEQfvICddi+AnEO2ycIOISw7UAVxieD/Cyz5mRMohfRSwoqoz+xNuIB+cj9loEB3Pw2448NaitKSLLRck2q5pOI9O9g/t/tkXda8Tbg0+PszB9FN8DuPaXKnKW4YcQn1Xk3HSIry5ps8UQ/2W5aQnxIwBdu7yFcgrxP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8FwhvEUAAAQQQcIIAAd4JtUgZEEAAAQQQ8BIgwHuB8BYBBBBAAAEnCBDgnVCLlAEBBBBAAAEvAQK8FwhvEUAAAQQQcIKArQL8iRMn5PLly05wpQwIIIAAAghYKmB5gJ8+fbrUqVNHsmfPLgUKFJAcOXJI6dKlpV+/fnL69GlLcTg5AggggAAC0SpgaYBfsGCBDBo0SEaMGCEHDx6UK1euyJkzZ2TRokWSLVs2ad++fbS6km8EEEAAAQQsFbA0wM+fP1+GDh0qLVu2NFfvmTJlkpw5c0rZsmVl9OjRsnv3btFmexICCCCAAAIIBCZgaYCvUa
|
||
|
|
||
|
<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>
|
||
|
|
||
|
<div class="chunk" id="setup"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl kwd">library</span><span class="hl def">(knitr)</span>
|
||
|
<span class="hl com"># to base64 encode images</span>
|
||
|
<span class="hl def">opts_knit</span><span class="hl opt">$</span><span class="hl kwd">set</span><span class="hl def">(</span><span class="hl kwc">upload.fun</span> <span class="hl def">= image_uri)</span>
|
||
|
</pre></div>
|
||
|
</div></div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|