Purpose
This script comprises my experiements on NIFTYBees dataset with the help of the plots mentioned in Positioning dataset

entry.exit , master and positions are already created before running this script.

> entry.exit.rel <- subset(entry.exit, duration > 0)
> entry.exit.rel$yr <- (as.POSIXlt(entry.exit.rel$entry))$year +
+     1900
> entry.exit.rel$yr <- as.factor(entry.exit.rel$yr)


pie chart

> p <- ggplot(master, aes(x = factor(1), fill = code))
> q <- p + geom_bar()
> r <- q + coord_polar(theta = "y") + xlab("") + ylab("")
> print(r)

Positioning-002.jpg



Bar Chart

> temp <- entry.exit.rel
> temp.master <- master[, c("id", "code")]
> temp <- merge(temp, temp.master, all.x = T)
> temp <- temp[temp$code != "FI" & temp$code != "FN", ]
> p <- ggplot(temp, aes(duration, fill = yr)) + ylab("")
> q <- p + geom_bar(binwidth = 10) + scale_fill_brewer(pal = "Set1") +
+     ylab("")
> print(q)

Positioning-003.jpg

> code <- as.character(temp$code)
> code.f <- factor(code)
> temp$code <- code.f
> temp <- temp[temp$code == "PUB", ]
> code <- as.character(temp$code)
> code.f <- factor(code)
> temp$code <- code.f

Positioning-004.jpg

boxplot

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q
> print(r)

Positioning-005.jpg

boxplot with jitter

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q + geom_jitter(colour = alpha("black", 1/20))
> print(r)

Positioning-006.jpg



facet_grid
Single row with multiple columns

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q + facet_grid(. ~ code)
> print(r)

Positioning-007.jpg

Single column with multiple rows

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q + facet_grid(yr ~ .)
> print(r)

Positioning-008.jpg

Multiple columns with Multiple rows

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q + facet_grid(yr ~ code)
> print(r)

Positioning-009.jpg

Multiple columns with Multiple rows and Margins

> p <- ggplot(temp, aes(x = yr, y = duration, fill = yr))
> q <- p + geom_boxplot(binwidth = 10)
> r <- q + facet_grid(yr ~ code, margins = T)
> print(r)

Positioning-010.jpg