How to visualise a DataSet according to its Class Variable in R

In [2]:
# -----------------------------------------------------------------
# How to visualise a DataSet according to its Class Variable in R 
# -----------------------------------------------------------------
# load the library
library(corrgram)
library(mlbench)
library(caret)

# load the data
data(iris)
DataSet <- as.data.frame(iris)

dim(DataSet)
X <- DataSet[, 1:4]; y <- DataSet[, 5]

# density plots for each attribute by class value
scales <- list(x=list(relation="free"), y=list(relation="free"))
featurePlot(x=X, y=y, plot="density", scales=scales)

# box and whisker plots for each attribute by class value
featurePlot(x=X, y=y, plot="box")

# more plots on each attribute by class value
featurePlot(x=X, y=y, plot="pairs")
featurePlot(x=X, y=y, plot="strip", jitter = TRUE)
  1. 150
  2. 5
In [ ]: