How to do it...

Perform the following steps to apply statistics to a dataset:

  1. Load the iris data into an R session:
        > data(iris)
  1. Observe the format of the data:
        > class(iris)
        [1] "data.frame"  
  1. The iris dataset is a DataFrame containing four numeric attributes: petal length, petal width, sepal width, and sepal length. For numeric values, you can perform descriptive statistics, such as mean, sd, var, min, max, median, range, and quantile. These can be applied to any of the four attributes in the dataset:
 > mean(iris$Sepal.Length) Output: [1] 5.843333 > sd(iris$Sepal.Length) Output: [1] 0.8280661 > var(iris$Sepal.Length) Output: [1] 0.6856935 > min(iris$Sepal.Length) Output: [1] 4.3 > max(iris$Sepal.Length) Output: [1] 7.9 > median(iris$Sepal.Length) ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.