Basic R commands and exploring Iris dataset

week1 post
hw1
shantanu patil
dataset
Author

Shantanu Patil

Published

February 23, 2022

Code
library(tidyverse)
library(readr)
knitr::opts_chunk$set(echo = TRUE)

Testing c function for integers and strings and seq functions

Code
x <- c(2,3,4,5,8, 6, 7, 5, 3, 0, 9)
mean(x)
[1] 4.727273
Code
names = c("Om", "Damian", "Sunny", "Oguz", "Jake", "Jain")
names
[1] "Om"     "Damian" "Sunny"  "Oguz"   "Jake"   "Jain"  
Code
y = seq(1, 14, 1.5)
y
[1]  1.0  2.5  4.0  5.5  7.0  8.5 10.0 11.5 13.0

Reading the iris dataset

The iris dataset is a built-in dataset in R. It can be loaded using the command data(iris)

Exploring the iris data

I decided to explore the iris data for my first post of week 1.

Iris is a flowering plant, and the researchers have measured and digitally documented the varied characteristics of the many iris blossoms.

The Iris data set has 150 rows and 5 colums.There are 3 Species of Iris plant present in the dataset.

The Colums are the various dimensions of the petals which are Sepal.Length, Sepal.Width, Petal.Length, Petal.Width, Species.

Code
data(iris)

names(iris)
[1] "Sepal.Length" "Sepal.Width"  "Petal.Length" "Petal.Width"  "Species"     
Code
dim(iris)
[1] 150   5
Code
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 ...

Summary of iris data

Using the summary function in R gives us the various statistics of the values of each column in the dataset.

Code
summary(iris)
  Sepal.Length    Sepal.Width     Petal.Length    Petal.Width   
 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100  
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300  
 Median :5.800   Median :3.000   Median :4.350   Median :1.300  
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199  
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800  
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500  
       Species  
 setosa    :50  
 versicolor:50  
 virginica :50