str(iris) # iris is a dataset
# partitioning of Graphic Display, 2 by 2
par(mfrow = c(2,2))
# 1. Drawing Histograms
for (k in 1:4) hist(iris[[k]])
# 2. Redrawing the Histograms
# 2-1) Making Main Title of the Histogram
title <- paste0("Histogram of ", colnames(iris[1:4])) ; title
# 2-2) Color
col <- c("yellow", "lightgreen", "lightpink", "skyblue"); col
# 2-3) Redrawing
for (k in 1:4) hist(iris[[k]],
main=title[k],
xlab=colnames(iris[k]),
ylab="Frequency",
col = col[k])
> # 2. Redrawing the Histograms
>
> # 2-1) Making Main Title of the Histogram
> title <- paste0("Histogram of ", colnames(iris[1:4])) ; title
## [1] "Histogram of Sepal.Length" "Histogram of Sepal.Width"
## [3] "Histogram of Petal.Length" "Histogram of Petal.Width"
>
> # 2-2) Color
> col <- c("yellow", "lightgreen", "lightpink", "skyblue"); col
## [1] "yellow" "lightgreen" "lightpink" "skyblue"
>
> # 2-3) Redrawing
> for (k in 1:4) hist(iris[[k]],
## + main=title[k],
## + xlab=colnames(iris[k]),
## + ylab="Frequency",
## + col = col[k])
>