Graphics Reference
In-Depth Information
Abe Drexler Peggy Olson
Allison Don Draper
Arthur Case Betty Draper
...
# Create a graph object from the data set
g
<-
graph.data.frame(madmen2, directed
=
TRUE
TRUE
)
# Remove unnecessary margins
par(mar
=
c(
0
,
0
,
0
,
0
))
plot(g, layout
=
layout.fruchterman.reingold, vertex.size
=
8
, edge.arrow.size
=
0.5
,
vertex.label
=
NNA
)
It's also possible to make a directed graph from a data frame. The
madmen
data set has only one
row for each pairing, since direction doesn't matter for an undirected graph. This time we'll use
a circle layout (
Figure 13-9
):
g
<-
graph.data.frame(madmen, directed
=
FALSE
FALSE
)
par(mar
=
c(
0
,
0
,
0
,
0
))
# Remove unnecessary margins
plot(g, layout
=
layout.circle, vertex.size
=
8
, vertex.label
=
NNA
)