install.packages("learningR", repos = "https://polmine.github.io/drat")
library(learningR) colnames(btw2017)[1:10]
barplot()
(Balkendiagramme)pie()
(Kuchendiagramme)plot()
text()
points()
lines()
hist()
(Histogramme), boxplot()
(Boxplots)Hinweis: Die "base R"-Funktionen sind generische Methoden, die ihr Verhalten abhängig vom Objekt ändern.
dev.off()
abschließen!):pdf()
bmp()
, png()
, tiff()
pdf_doc <- tempfile(fileext = ".pdf") pdf(file = pdf_doc) hist(btw2017[["Wähler/Zweitstimmen/Endgültig"]] / btw2017[["Wahlberechtigte/Zweitstimmen/Endgültig"]]) dev.off()
?par
par()
duis_districts <- grep("Duisburg", btw2017[["Gebiet"]]) parties <- c(black = "CDU", red = "SPD", yellow = "FDP", pink = "LINKE", green = "GRUENE", blue = "AfD") columns <- paste(parties, "Zweitstimmen", "Endgültig", sep = "/") votes <- unlist(btw2017[duis_districts[1], columns]) names(votes) <- sapply(strsplit(names(votes), "/"), `[`, 1L) votes_total <- as.integer(btw2017[duis_districts[1],"Wähler/Zweitstimmen/Endgültig"]) votes <- c(votes, Sonstige = votes_total - sum(votes)) percent <- round(votes / votes_total * 100, 1) names(percent) <- paste(names(percent), " (", unname(percent), "%)", sep = "") pie( percent, labels = names(percent), col = c(names(parties), "darkgrey"), main = "Duisburg I", cex = 1 )
par(mfrow = c(1, 2)) par(mar = c(1, 1, 1, 1)) get_votes <- function(i){ votes <- unlist(btw2017[i, columns]) names(votes) <- sapply(strsplit(names(votes), "/"), `[`, 1L) votes } for (i in 1L:length(duis_districts)){ v <- get_votes(duis_districts[i]) pie(v, labels = names(v), col = names(parties), cex = 0.6, main = btw2017[duis_districts[i], "Gebiet"]) }
gruene_share <- btw2017[["GRUENE/Zweitstimmen/Endgültig"]] / btw2017[["Wähler/Zweitstimmen/Endgültig"]] btw2017[["GRÜNE/Prozent"]] <- round(gruene_share * 100, 1) btw2017_gr <- btw2017[order(btw2017[["GRÜNE/Prozent"]], decreasing = TRUE),] btw2017_min <- subset(btw2017_gr, gehört.zu != 99)[1:10,] barplot(btw2017_min[["GRÜNE/Prozent"]], names.arg = btw2017_min[["Gebiet"]], las = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.