First knitr tests

# knitr::opts_chunk$set(echo=FALSE,results="hide")

Code chunks can have names! Good for plots, apparently.

1+1
## [1] 2

option echo= FALSE does not include the code

## [1] 3

you can also include variables in the middle of the text. The following text is not displayed in the html

The current time is Mo Jul 22 10:32:53 2019. My favorite number is -1.3924333.

The following hides the results with the use of results=“hide”:

1+1

Using figures and specifying height:

x <- rnorm(100); y <- x + rnorm(100,sd=0.5)
plot(x,y,main="Data")

We can also make tables using xtable, use results=“asis”

data(airquality)
library(xtable)
## Warning: package 'xtable' was built under R version 3.6.1
fit <- lm(Ozone~Wind+Temp+Solar.R,data=airquality)
xt <- xtable(summary(fit))
print(xt,type="html")
Estimate Std. Error t value Pr(>|t|)
(Intercept) -64.3421 23.0547 -2.79 0.0062
Wind -3.3336 0.6544 -5.09 0.0000
Temp 1.6521 0.2535 6.52 0.0000
Solar.R 0.0598 0.0232 2.58 0.0112

We can also cache code chunks that take a long time to run, with the option cache=TRUE. But be careful with changing stuff that depends on other chunks.