2

I have a data set with a nominale variable "count session" and three other quantitatives variables including wildlife counts from three different methods. I would like to plot my group sizes from the different methods (y-axis) against the count session. I am a beginner with R. Do you know any function that would allow me to do that?

@siva974: Data belongs in the question not in comments:

 COUNT 
SESSION MEANVISUAL MEANOVERLAP MEANWIDEANGLE 
1 290 286 NA 
2 137 132 120 
3 289 280 289 
4 310 287 250 
5 280 286 260 
6 139 142 144
4

1 回答 1

2

Generally in base graphics you would create an initial plot using one variable on the y-axis (but leaving room to add the others), then use the function points or lines to add the additional variables to the existing plot.

There are alternative ways to plot such as ggplot2 or lattice graphics, sometimes it is easier to make complicated plots using these tools (and sometimes it is harder).

If you can give more detail on your data and what you would like the plot to look like then we can give more help.

A first try would be something like:

with(COUNT, plot(SESSION, MEANVISUAL, type='b', 
  ylim=range(MEANVISUAL,MEANOVERLAP,MEANWIDEANGLE)))
with(COUNT, lines(SESSION, MEANOVERLAP, type='b', col='blue', pch=2))
with(COUNT, lines(SESSION, MEANWIDEANGLE, type='b', col='green', pch=3))

Or possibly use the matplot function:

matplot( COUNT$SESSION, COUNT[ , 2:4], type='b' )
于 2013-03-29T21:12:21.920 回答