tmp1 <- table(visit_cmatrix[,2])
tmp1 <- data.frame(names(tmp1), cbind(tmp1))
colnames(tmp1) <- c('WebsiteCategory','1')
for ( i in 3:21) {
tmp <- table(visit_cmatrix[,i])
tmp <- data.frame(names(tmp), cbind(tmp))
colnames(tmp) <- c('WebsiteCategory', paste("", i-1, sep = ""))
tmp1 <- merge(tmp1, tmp, by = 'WebsiteCategory')
}
tmp1 <- tmp1[sort.list(tmp1[,2], decreasing = F),]
tmp1[,1] <- factor(tmp1[,1], levels = tmp1[,1])
tmp2 <- melt(tmp1, id ='WebsiteCategory')
tmp3 <- ddply(tmp2, .(variable), transform, rescale = rescale(value))
ggplot(tmp3, aes(variable, WebsiteCategory)) +
geom_tile(aes(fill = rescale, order = rescale), colour = "white") +
scale_fill_gradient(name = "Rescale of \n # users", low = "lightblue", high = "red") +
xlab("Visits") + ylab("Website Category") +
opts(axis.text.x = theme_text(face = "bold", size = 12)) +
opts(axis.text.y = theme_text(face = "bold", size = 12)) +
opts(axis.title.x = theme_text(face = "bold", size = 12)) +
opts(axis.title.y = theme_text(face = "bold", size = 12, angle = 90)) +
opts(title = "HeatMap of Multiple Visit Categories") +
opts(plot.title = theme_text(face = "bold", size=14))
Subscribe to:
Post Comments (Atom)
Blog Archive
-
▼
2015
(43)
-
▼
December
(14)
- Master R 4 - Restruct Data
- Master R 3 - Filter and Summarize Data
- Master R 2 - Fetch Web Data
- Master R 1 - Readin Data
- Visual 10 - Bipartite Network Plot in R
- Visual 9 - Heat Map in R
- Visual 8 - Dot Plot and Bubble Chart
- Visual 7 - Network Graph
- Visual 6 - Density
- Visual 5 - Bar Chart and Stacked Bar Chart
- Visual 4 - Bloxplot and Donut Chart
- Visual 3 - Line Plot
- Visual 2 - Histogram
- Visual 1 - Corrlation
-
▼
December
(14)
No comments:
Post a Comment