Again, for your convenience, you can load the data for this exercise using the following code:
library(dplyr)
library(haven)
allbus_2021_dvI <-
read_sav(
"./data/allbus_2021ZA5280_v1-0-0.sav"
) %>%
sjlabelled::set_na(na = c(-1:-99, 97, 98))
par()
function in combination with its mfrow
option.
tab_1 <- table(allbus_2021_dvI$fr09)
tab_2 <- table(allbus_2021_dvI$fr10)
tab_3 <- table(allbus_2021_dvI$fr11)
tab_4 <- table(allbus_2021_dvI$fr12)
par(mfrow = c(2, 2))
barplot(tab_1)
barplot(tab_2)
barplot(tab_3)
barplot(tab_4)
That’s interesting. One may wonder what the median is in each of these distributions. You know what’s perfect for visualizing this statistic? Boxplots!
par(mfrow = c(2, 2))
boxplot(allbus_2021_dvI$fr09)
boxplot(allbus_2021_dvI$fr10)
boxplot(allbus_2021_dvI$fr11)
boxplot(allbus_2021_dvI$fr12)
png
image.
png("Boxlots.png")
par(mfrow = c(2, 2))
boxplot(allbus_2021_dvI$fr09)
boxplot(allbus_2021_dvI$fr10)
boxplot(allbus_2021_dvI$fr11)
boxplot(allbus_2021_dvI$fr12)
dev.off()
## png
## 2
Before we later start with the other exercises, you should clean your graphics device with dev.off()
dev.off()
## null device
## 1