[R] Lattice xyplot

array chip arrayprofile at yahoo.com
Mon May 1 03:07:19 CEST 2017


Dear all, I am new to lattice, so would appreciate anyone's help on the questions below. I am using xyplot to plot some trend in my dataset. Using the example dataset attached, I am trying to plot variable "y" over variable "time" for each subject "id":
dat<-read.table("dat.txt",sep='\t',header=T,row.names=NULL)
xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p", "l"),  xlab = "Time", ylab = "Y")

It appears that it just worked fine. But if I sort the "dat" first, the plot will look somewhat different!
dat<-dat[order(dat$id, dat$time),]xyplot(y ~ time, data=dat, groups=id, aspect = "fill", type = c("p", "l"),  xlab = "Time", ylab = "Y")
Why is that? Do you need to sort the data first before using xyplot? Why xyplot can not understand the dataset unless it is sorted first?
Thanks,
John
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dat.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20170501/432a8fd6/attachment.txt>


More information about the R-help mailing list