thomasp85 / ggraph

Grammar of Graph Graphics
https://ggraph.data-imaginist.com
Other
1.08k stars 116 forks source link

igraph example fails: ggplot2 doesn't know how to deal with data of class function #4

Closed MarkEdmondson1234 closed 8 years ago

MarkEdmondson1234 commented 8 years ago

I got this error, then trying the example in the readme I got the same:

friendGraph <- graph_from_data_frame(highschool)
V(friendGraph)$degree <- degree(friendGraph, mode = 'in')
graph1957 <- subgraph.edges(friendGraph, which(E(friendGraph)$year ==1957), F)
graph1958 <- subgraph.edges(friendGraph, which(E(friendGraph)$year ==1958), F)
V(friendGraph)$pop.increase <- degree(graph1958, mode = 'in') > 
  degree(graph1957, mode = 'in')

ggraph(friendGraph, 'igraph', algorithm = 'kk') + 
  geom_edge_fan(aes(alpha = ..index..)) + 
  geom_node_point(aes(size = degree, colour = pop.increase)) + 
  scale_edge_alpha('Friends with', guide = 'edge_direction') + 
  scale_colour_manual('Improved', values = c('firebrick', 'forestgreen')) + 
  scale_size('# Friends') + 
  facet_wrap(~year) + 
  ggforce::theme_no_axes()

Error: ggplot2 doesn't know how to deal with data of class function

I came across it when adding the geom_node_point geom for my own graph:

ggg <- ggraph::ggraph(graph, "igraph", algorithm = 'nicely')
ggg <- ggg + ggraph::geom_node_point()

ggg ## all is well

ggg + ggraph::geom_edge_fan()
Error: ggplot2 doesn't know how to deal with data of class function
thomasp85 commented 8 years ago

You need the devel version of ggplot2 until the next version is available on CRAN as per the readme