[R] Line plot using xyplot function in lattice package
Hi All, For the following data when I use xyplot in package lattice the intervals are in the order of 2, 24, 8, but instead I want them to be in the order 2, 8, 24. Treatment Interval value A 2 0.448 A24 1.85 A 8 1.166 B 2 1.074 B24 1.5 B 8 1.065 C20.854 C 8 0.589 The R script is xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment, Is there a way in xyplot to specify the order?. -Sandeep [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Line plot using xyplot function in lattice package
Ghosh, Sandeep wrote on 3/17/2005 1:25 PM: Hi All, For the following data when I use xyplot in package lattice the intervals are in the order of 2, 24, 8, but instead I want them to be in the order 2, 8, 24. Treatment Interval value A 2 0.448 A24 1.85 A 8 1.166 B 2 1.074 B24 1.5 B 8 1.065 C20.854 C 8 0.589 The R script is xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment, Is there a way in xyplot to specify the order?. -Sandeep Hi Sandeep, You can make Interval an ordered variable: studyData$Interval - ordered(studyData$Interval, c(2, 24, 8)) xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment) --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Line plot using xyplot function in lattice package
Sundar Dorai-Raj wrote on 3/17/2005 2:27 PM: Ghosh, Sandeep wrote on 3/17/2005 1:25 PM: Hi All, For the following data when I use xyplot in package lattice the intervals are in the order of 2, 24, 8, but instead I want them to be in the order 2, 8, 24. Treatment Interval value A 2 0.448 A 241.85 A 8 1.166 B 2 1.074 B 241.5 B 8 1.065 C 2 0.854 C 8 0.589 The R script is xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment, Is there a way in xyplot to specify the order?. -Sandeep Hi Sandeep, You can make Interval an ordered variable: studyData$Interval - ordered(studyData$Interval, c(2, 24, 8)) xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment) --sundar Sorry I misread your original message. You just need to re-order the data, as in: studyData - studyData[do.call(order, studyData), ] xyplot(value ~ Interval, data=studyData, type='b', groups = Treatment) HTH, --sundar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html