Poop Sheet

Iris

Iris is one of the databases built into R (ie it can be accessed without loading), and used by Learn R through examples among others to teach the basics.

Other built-in datasets include:

The data() function provides the full list.

> str(iris)
'data.frame':	150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
svg("pie.svg", width = 11, pointsize = 12, family = "sans")
pie(table(iris$Species))
dev.off()

Pie chart of species, 50 each

svg("petal-width-length.svg", width = 11, pointsize = 12, family = "sans")
plot(Petal.Length ~ Petal.Width, data = iris, col = Species)
legend("topleft", levels(iris$Species), fill = 1:3)
abline(lm(Petal.Length ~ Petal.Width, data = iris))
dev.off()

Petal width to length scatterplot

svg("sepal-length.svg", width = 11, pointsize = 12, family = "sans")
boxplot(formula = Sepal.Length ~ Species, data = iris)
dev.off()

Boxplot of Sepal Length

svg("sepal-width.svg", width = 11, pointsize = 12, family = "sans")
boxplot(formula = Sepal.Width ~ Species, data = iris)
dev.off()

Boxplot of Sepal Width

svg("petal-length.svg", width = 11, pointsize = 12, family = "sans")
boxplot(formula = Petal.Length ~ Species, data = iris)
dev.off()

Boxplot of Petal Length

svg("petal-width.svg", width = 11, pointsize = 12, family = "sans")
boxplot(formula = Petal.Width ~ Species, data = iris)
dev.off()

Boxplot of Petal Width