28 lines
604 B
R
28 lines
604 B
R
#
|
|
# Pie charts
|
|
#
|
|
|
|
# Load data
|
|
htypes <- read.csv("data/household-types.tsv", sep="\t")
|
|
h2021 <- htypes[htypes$year == 2021,]
|
|
h2021_alpha <- h2021[order(h2021$htype, decreasing=TRUE),]
|
|
h2021_num <- h2021[order(h2021$p),]
|
|
|
|
|
|
#
|
|
# Pie chart, sorted and unsorted
|
|
#
|
|
|
|
par(mfrow=c(1,2))
|
|
pie(h2021_alpha$p, labels=h2021_alpha$htype, init.angle=90, col = "gray")
|
|
pie(h2021_num$p, labels=h2021_num$htype, init.angle=90, col = "gray")
|
|
|
|
|
|
#
|
|
# Bar chart, sorted and unsorted
|
|
#
|
|
|
|
par(mfrow=c(1,2))
|
|
barplot(h2021_alpha$p, names.arg=h2021_alpha$htype, horiz=TRUE)
|
|
barplot(h2021_num$p, names.arg=h2021_num$htype, horiz=TRUE)
|