Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

library(ggplot2)

> counts <- c(124, 94, 86, 41, 25, 14, 8, 5, 1)

> defects <- c("food cold.", "too much time in line.", "no vegetarian choice.", "not enough selection of
food items.", "too much ice in sodas.", "food too expensive.", "server rude.", "no chili for hot dogs.",
"dirty counter.")

> dat <- data.frame(Complaints= counts,Frequency = defects,stringsAsFactors = FALSE)

> dat <- dat[order(dat$count, decreasing=TRUE), ]

> dat$defect <- factor(dat$defect, levels=dat$defect)

> dat$cum <- cumsum(dat$count)

> library(ggplot2)

> ggplot(dat, aes(x=defect)) + geom_bar(aes(y=count), fill="blue", stat="identity") +


geom_point(aes(y=cum)) + geom_path(aes(y=cum, group=1))

You might also like