library(ggplot2)
library(dplyr)
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

Data manipulation steps:

  1. Convert measurements from centimeters to inches
  2. Compute two ratio features: ratio of lengths (sepal : petal) and ratio of widths (sepal : petal)
  3. Create a new feature: circumference of the smallest circle that could circumscribe the flower (using the larger length as the radius).
iris[,1:4] <- iris[,1:4]/2.54
iris$Length.Ratio <- iris$Sepal.Length/iris$Petal.Length
iris$Width.Ratio <- iris$Sepal.Width/iris$Petal.Width

r <- iris$Sepal.Length*(iris$Sepal.Length > iris$Petal.Length) + 
     iris$Petal.Length*(iris$Petal.Length >= iris$Sepal.Length)
iris$Circumference <- 2*pi*r
head(iris)
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species Length.Ratio Width.Ratio Circumference
## 1     2.007874    1.377953    0.5511811  0.07874016  setosa     3.642857       17.50      12.61584
## 2     1.929134    1.181102    0.5511811  0.07874016  setosa     3.500000       15.00      12.12111
## 3     1.850394    1.259843    0.5118110  0.07874016  setosa     3.615385       16.00      11.62637
## 4     1.811024    1.220472    0.5905512  0.07874016  setosa     3.066667       15.50      11.37900
## 5     1.968504    1.417323    0.5511811  0.07874016  setosa     3.571429       18.00      12.36848
## 6     2.125984    1.535433    0.6692913  0.15748031  setosa     3.176471        9.75      13.35795

Pairs plot of all variables

pairs(iris)

Plot of circumference and length ratio by species

iris %>% ggplot(aes(
  x = Circumference, 
  y = Length.Ratio, 
  color = Species
)) +
  geom_point() +
  theme_classic() +
  theme(
    legend.position = 'top',
    legend.justification = 'left'
  )