Module 11. Assignment
I read Dr. Piwek's talk on Edward Tufte and Charles Minard for this module, and then I made the dot-dash plot again using basic R. I noticed that the basic R version was the only one that could make the visual displayed in my attached figure after I installed and loaded all the visualization packages. I used the code that came with the module to make a graph of per-capita budget spending. It showed a range of years from 1967 to 1977 and the y values that went with them. The plot(), axis(), and abline() methods produced the linked points and dashed reference lines at 5 and 6. The text() function added notes for the 5 percent line and an explanatory caption. The output shows Tufte's minimalist design principle: it is clean, focused on data, and simple to understand.
pkgs <- c("CarletonStats","devtools","epanetReader","fmsb","ggplot2","ggthemes","latticeExtra","MASS","PerformanceAnalytics","psych","plyr","prettyR","plotrix","proto","RCurl","reshape","reshape2"); utils::install.packages(pkgs, dependencies=TRUE, repos="https://cloud.r-project.org")
library(CarletonStats); library(devtools); library(epanetReader); library(fmsb)
library(ggplot2); library(ggthemes); library(latticeExtra); library(MASS)
library(PerformanceAnalytics); library(psych); library(plyr); library(prettyR)
library(plotrix); library(proto); library(RCurl); library(reshape); library(reshape2)
x <- 1967:1977
y <- c(0.5,1.8,4.6,5.3,5.3,5.7,5.4,5,5.5,6,5)
pdf("dot_dash_base.pdf", width = 10, height = 6) # saves to your working folder
par(family = "serif")
plot(y ~ x, axes = FALSE, xlab = "", ylab = "", pch = 16, type = "b")
axis(1, at = x, labels = x, tick = FALSE, family = "serif")
axis(2, at = seq(1, 6, 1), labels = sprintf("$%s", seq(300, 400, 20)),
tick = FALSE, las = 2, family = "serif")
abline(h = 6, lty = 2)
abline(h = 5, lty = 2)
text(max(x), min(y) * 2.5,
"Per capita\nbudget expenditures\nin constant dollars",
adj = 1, family = "serif")
text(max(x), max(y) / 1.08, labels = "5%", family = "serif")
dev.off()
getwd()
list.files()
shell.exec("dot_dash_base.pdf")
p <- normalizePath("dot_dash_base.pdf")
system2("cmd", c("/c", "start", "", shQuote(p)))
Comments
Post a Comment