-
-
Save smc-dta/2f0dae43728459edb646 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set.seed(1234) | |
dat <- data.frame( | |
product=c(rep("Mobile",2), | |
rep(c("Smartphone", "Mobile"),3), | |
rep(c("Video rental shop"),3), | |
rep(c("Video rental shop", | |
"Online movie rental"),2)), | |
year=c(2008:2010, 2010, 2011, 2011, 2012, 2012, | |
2008:2010, 2011, 2011, 2012, 2012), | |
category=c(rep("Phone", 8), rep("Film", 7)), | |
price.change=rnorm(15, 0, 0.1)+0.1) | |
dat$product <- with(dat, factor(product, | |
levels=levels(product)[c(1,3,4,2)], | |
ordered=TRUE)) | |
library(lattice) | |
my.settings <- canonical.theme(color=FALSE) | |
my.settings[['strip.background']]$col <- "black" | |
my.settings[['strip.border']]$col<- "black" | |
barchart(price.change ~ factor(year) | product, | |
data=dat, | |
layout=c(2,2), | |
par.settings = my.settings, | |
par.strip.text=list(col="white", font=2), | |
horizontal=FALSE, origin=0, | |
scales=list(cex=c(1.1, 1.1)), # increase font size | |
xlab=list(label="Year", fontsize=14), | |
ylab=list(label="Price change", fontsize=14), | |
panel=function(x,y,...){ | |
panel.abline(h=0) | |
panel.barchart(x,y,...) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment