Set up the size of plots in the output

A few additional options: warning=FALSE and message=FALSE suppress any R warnings or messages from being included in the final document; fig.width=5, fig.height=4) set up the size of plots.

VI. Import data and summarize data

tips <- read.csv("http://www.ggobi.org/book/data/tips.csv")
library(knitr)
kable(summary(tips))
obs totbill tip sex smoker day time size
Min. : 1.00 Min. : 3.07 Min. : 1.000 F: 87 No :151 Fri:19 Day : 68 Min. :1.00
1st Qu.: 61.75 1st Qu.:13.35 1st Qu.: 2.000 M:157 Yes: 93 Sat:87 Night:176 1st Qu.:2.00
Median :122.50 Median :17.80 Median : 2.900 NA NA Sun:76 NA Median :2.00
Mean :122.50 Mean :19.79 Mean : 2.998 NA NA Thu:62 NA Mean :2.57
3rd Qu.:183.25 3rd Qu.:24.13 3rd Qu.: 3.562 NA NA NA NA 3rd Qu.:3.00
Max. :244.00 Max. :50.81 Max. :10.000 NA NA NA NA Max. :6.00

VII. Including Plots

You can also embed plots, for example:

library(ggplot2)
p<-ggplot(data=tips,aes(smoker,fill=time))
p + geom_bar(width=0.5)

Note that the echo = FALSE can be added to the code chunk to prevent printing of the R code.