require(igraph)
require(NetIndices)
require(ggplot2)
ggbigraph <- function(g) {
g_ <- get.edgelist(g)
g_df <- as.data.frame(g_)
g_df$id <- 1:length(g_df[,1])
g_df <- melt(g_df, id=3)
xy_s <- data.frame(value = unique(g_df$value),
x = c(rep(2, length(unique(g_df$value))/2), rep(4, length(unique(g_df$value))/2)),
y = rep(seq(1, length(unique(g_df$value))/2, 1), 2))
g_df2 <- merge(g_df, xy_s, by = "value")
p <- ggplot(g_df2, aes(x, y)) +
geom_point() +
geom_line(size = 0.3, aes(group = id, col = id)) +
geom_text(size = 3, hjust = 2, aes(label = value)) +
theme_bw() +
opts(panel.grid.major=theme_blank(),
panel.grid.minor=theme_blank(),
axis.text.x=theme_blank(),
axis.text.y=theme_blank(),
axis.title.x=theme_blank(),
axis.title.y=theme_blank(),
axis.ticks=theme_blank(),
panel.border=theme_blank(),
legend.position="none")
p
}
i <- 2
cool <- ddply(visit_cmatrix, .(visit_cmatrix[,i], visit_cmatrix[,i+1]), nrow)
level <- levels(result2$category)
x<-as.numeric(factor(cool[,1], level, exclude=NULL))
y<-as.numeric(factor(cool[,2], level, exclude=NULL)) + 24
tmp <- cbind(x,y)
tmp <- rbind(c(NA,NA),tmp)
for (i in 1:ncol(tmp)){
x <- tmp[,i]
x[is.na(x)] <- 0 + (i-1) *24
tmp[,i] <- x
}
g <- graph.data.frame(tmp, directed=FALSE)
ggbigraph(g)
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