
Loading Data
## '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 ...
Scatter Plot
par(lwd= 2)
plot(iris$Sepal.Length,
iris$Sepal.Width,
pch= 19,
col= iris$Species, cex= 1.5,
xlab= "Sepal Length",
ylab= "Sepal Width",
main= "ScatterPlot of Iris Dataset")
legend(
"topright",
legend = levels(iris$Species),
pch = 19,
col = 1:3,
title = "Species",
title.col = "red",
bty = "n",
horiz = T
)

Histogram with Normal line
par(mfrow= c(2,2), lwd= 2)
for(i in 1:4) {
rcompanion::plotNormalHistogram(iris[i],
col= i+2,
main= names(iris)[i],
xlab= "")
}

Box plot
par(mfrow= c(1,1))
par(lwd= 2)
boxplot(iris$Sepal.Length~iris$Species,
col= 2:4,
ylab= "Species",
xlab= "Sepal Length",
horizontal = T,
pch= 19,
main= "Boxplot ~ Species")

par(lwd= 2)
par(mfrow= c(2,2), mar= c(2.5,1,2.5,1))
for(i in 1:4) {
boxplot(iris[i],
main= colnames(iris)[i],
col= i+1,
horizontal = T,
pch= 19)
}

par(lwd= 4)
pie(
table(iris$Species),
col = c("tomato2", "steelblue", "palegreen4"),
border = "white",
main = "Pie Chart",
radius = 1,
labels = paste(table(iris$Species) |> names(),
table(iris$Species))
)

Bar plot
Counts <- c(352, 174, 31, 8)
Enrollments <- c("UG", "PG", "PhD", "PDF")
barplot(
Counts,
names.arg = Enrollments,
col = 2:5,
main = "Barplot",
border = 2:5
)
