This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(datasets)
data("iris")
dim(iris)
## [1] 150 5
head(iris)
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3.0 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5.0 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
table(iris$Species)
##
## setosa versicolor virginica
## 50 50 50
You can also embed plots, for example:
# Boxplot: good for compparing data
boxplot(iris)
## Red line is mean
abline(h = mean(iris$Petal.Length), col="red")
# Historgram
hist(iris$Petal.Length)
## more granular
hist(iris$Sepal.Length, breaks = 100, col = "green")
# Barplot
barplot(table(iris$Species))
# Lattice ----
library(lattice)
plot(iris$Sepal.Width, iris$Sepal.Length)
xyplot(Sepal.Length ~ Sepal.Width | Species, data = iris)
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.