2024-02-05

Dataset Iris

  • A dataset of 150 iris plants
  • 3 classes/types of iris plant
  • Obtained on 1936 by Fisher, one of earliest datasets for statistics
  • Example of application of Statistics on Biology
data(iris)
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

Code for Sepal Length vs Petal Length

mod = lm(Petal.Length ~ Sepal.Length, data=iris)
x = iris$Sepal.Length
y = iris$Petal.Length

xaxis <- list(
  title = "Sepal Length"
)
yaxis<- list(
  title = "Petal Length"
)
fig <-plot_ly(iris, x=x, y=y, type="scatter", mode="markers",
  width = 600, height=400) %>%
  add_trace(x=x, y=fitted(mod), type="scatter", mode="lines") %>%
  layout(xaxis = xaxis, yaxis = yaxis)

Plot of Sepal Length vs Petal Length

fig