Graphics Reference
In-Depth Information
in the specified range. As in Plotting a Function , we can improve the approximation by increas-
ing the number of interpolated values with stat_function(n=200) .
Creating a Network Graph
Problem
You want to create a network graph.
Solution
Use the igraph package. To create a graph, pass a vector containing pairs of items to graph() ,
then plot the resulting object ( Figure 13-7 ):
# May need to install first, with install.packages("igraph")
library(igraph)
# Specify edges for a directed graph
gd <- graph(c( 1 , 2 , 2 , 3 , 2 , 4 , 1 , 4 , 5 , 5 , 3 , 6 ))
plot(gd)
# For an undirected graph
gu <- graph(c( 1 , 2 , 2 , 3 , 2 , 4 , 1 , 4 , 5 , 5 , 3 , 6 ), directed = FALSE
FALSE )
# No labels
plot(gu, vertex.label = NNA )
Search WWH ::




Custom Search