Movatterモバイル変換


[0]ホーム

URL:


This is an R HTML vignette. The file extension is*.Rhtml, andit has to include a special comment to tell R that this file needs to becompiled byknitr:

<!--%\VignetteEngine{knitr::knitr}%\VignetteIndexEntry{The Title of Your Vignette}-->

Now you can write R code chunks:

summary(cars)
##      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
fit=lm(dist~speed,data=cars)summary(fit)
## ## 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

You can also embed plots, for example:

par(mar=c(4,4,.1,.1))plot(cars,pch=19)
plot of chunk cars-plot

For package vignettes, you need to encode images in base64 strings using theknitr::image_uri() function so that the image files are no longerneeded after the vignette is compiled. For example, you can add this chunk inthe beginning of a vignette:

library(knitr)# to base64 encode imagesopts_knit$set(upload.fun= image_uri)

[8]ページ先頭

©2009-2025 Movatter.jp