Hi all, My apologies if this is a very simple problem. I am very new to R, having worked a lot previously with Excel. I recently completed a R course with John Hoenig which introduced me to R. My data: X Y Species Group 0 0 A 1 . . A 1 . . A 1 . . A 1 . . A 1 . . A 1 99 1 A 1 0 0 B 1 . . B 1 . . B 1 . . B 1 99 1 B 1 etc etc etc etc with variable numbers between 0 and 99 and 0 and 1 for each species. I have about 30 different species, each catergorised as 1 of 3 groups. I want to plot X vs Y for each species onto the same plot, using lines. In other words, I need 30 different lines each plotted between 0 and 1 on the x axis and 0 and 100 on the y, but they need to be grouped by the Species, otherwise the lines return from 100 to 0 at the end of the data from each species. Any help would be greatly appreciated, Thanks -- Adrian Hordyk PhD Candidate Centre for Fish and Fisheries Biological Sciences and Biotechnology Murdoch University Phone: (08) 93606520 Mobile: 0438113583 Email: A.Hordyk at Murdoch.edu.au
Ado wrote:> > > My data: > > X Y Species Group > 0 0 A 1 > . . A 1 > . . A 1 > I want to plot X vs Y for each species onto the same plot, using lines. > In other words, I need 30 different lines each plotted between 0 and 1 on > the x axis and 0 and 100 on the y, but they need to be grouped by the > Species, otherwise the lines return from 100 to 0 at the end of the data > from each species. > >Probably not exactly what you want, but some permutations of group and |Species should work. Dieter library(lattice) n= 200 dat = data.frame(X=sample(1:99,n,TRUE), Y=sample(0:1,n,TRUE), Species=sample(c("A","B"),n,TRUE),Group=as.factor(sample(1:3,n,TRUE))) # avoid criss-cross by ordering dat = dat[with(dat,order(X,Y,Species,Group)),] xyplot(X~Y|Species, group=Group,data=dat,type="l") -- View this message in context: http://r.789695.n4.nabble.com/Plotting-by-Group-tp2994780p2994867.html Sent from the R help mailing list archive at Nabble.com.