Data Science Desktop Survival Guide
by Graham Williams |
|||||
KnitR Basic Example |
20200602 Our first example of running actual R code will generate some random uniform data using stats::runif() and then viewing the utils::head() of the data and calculating the base::mean(). The following code block shows how this will look in the source .Rnw file.
Below is what it looks like after it is processed by knitr and then LaTeX (as happens when we click the Compile PDF button in ).
|
# Always include a short comment to support the code.
x <- runif(1000) * 1000 head(x)
mean(x)
Notice that the syntax is colour highlighted and the output is
included as comments introduced in R with the
|