# NOT RUN {
require("ggplot2")
## Tufte's Cancer Graph (to the correct scale)
data(cancer)
ggslopegraph(cancer, col.lines = 'gray',
xlabels = c('5 Year','10 Year','15 Year','20 Year'))
## Tufte's GDP Graph
data(gdp)
ggslopegraph(gdp, col.line='gray', xlabels = c('1970','1979'),
main = 'Current Receipts of Goverment\nas a Percentage of Gross Domestic Product') +
theme_bw()
## Ranking of U.S. State populations
data(states)
ggslopegraph(states,
main = 'Relative Rank of U.S. State Populations, 1790-1870',
yrev = TRUE)
cls <- rep("black", nrow(states))
cls[rownames(states) == "South Carolina"] <- "red"
cls[rownames(states) == "Tennessee"] <- "blue"
ggslopegraph(states, main = 'Relative Rank of U.S. State Populations, 1790-1870',
yrev = TRUE, col.lines = cls, col.lab = cls)
## ranking of U.S. Bachelors Degrees fields
data(bachelors)
bachelors[] <- lapply(bachelors, function(x) rank(x))
names(bachelors) <- substring(names(bachelors), 3, 7)
ggslopegraph(bachelors, offset.x = 0, xlim = c(1, 25), col.num = NA, labpos.left = NULL)
# }
Run the code above in your browser using DataLab