[R] Help with doing overlays plots...
Jamieson Cobleigh
cobleigh at gmail.com
Mon Aug 8 19:03:09 CEST 2005
I have a data frame with three columns, type (a factor with two
values: "Monolithic" and "Compositional"), size (numeric), and states
(numeric). I want to create a plot where size goes on the x-axis and
states goes on the y-axis. In this plot, I want two lines, one where
the type is "Monolithic" and one where the type is "Compositional".
I think this can be done by using the plot command to plot the line
for one of the two types (setting the xlim and ylim parameters to
ensure the plot area is large enough to hold all of the points).
Then, I can use the lines and points commands to add the second line
onto the plot.
However, I don't want to have to specify the legend manually. I want
something in R that does what can be done in SAS by using "plot
states*size=type" in "proc gplot".
Here is a dump of my data set:
tmp <-
structure(list(type = structure(as.integer(c(2, 2, 2, 1, 1, 1,
1, 1)), .Label = c("Compositional", "Monolithic"), class = "factor"),
size = as.integer(c(2, 3, 4, 2, 3, 4, 5, 6)), states = as.integer(c(4910,
336026, 37526650, 4016, 44941, 310553, 8260254, 144145585
))), .Names = c("type", "size", "states"), row.names = c("1",
"2", "3", "4", "5", "6", "7", "8"), class = "data.frame")
More information about the R-help
mailing list