--- title: "R Notebook Tutorial" author: "Sean Horvath" date: "`r format(Sys.time(), '%d %B, %Y')`" output: html_notebook: default pdf_document: default --- This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code. # The Basics ### Simple R chunk Run code in *chunks* like below: ```{r} my_matrix <- matrix(c('a','b','c',1,2,3),nrow=3) my_matrix class(my_matrix[1,1]);class(my_matrix[1,2]) my_df <- data.frame(Char=c('a','b','c'),Num=c(1,2,3)) my_df class(my_df[1,1]);class(my_df[1,2]) my_df <- data.frame(Char=c('a','b','c'),Num=c(1,2,3), stringsAsFactors=F) my_df class(my_df[1,1]);class(my_df[1,2]) my_df[1,2] my_df$Num[1] ``` ### Only display the output You can use **chunk options** to control how individual R chunks are displayed. ```{r echo=FALSE} library(reshape2) names(airquality) <- tolower(names(airquality)) head(airquality) aqm <- melt(airquality, id=c("month", "day"), na.rm=TRUE, variable.name='Atmosphere',value.name='Measurement') head(aqm) ``` Some useful chunk options are `warnings=FALSE` `message=FALSE` ### Font colors Roses are $\color{red}{\text{red}}$, violets are $\color{blue}{\text{blue}}$