Hi everybody,

I recently used xyplot, but I found that for control flow can't work in the
xyplot. The program code and some of my data file are shown as follow.
Would someone please tell me where my code is wrong and how can make the
code right?

Thanks.

Best regards
Yuanzhen Lin


Code:

library("lattice")

plot.data$Fam<-as.numeric(plot.data$Fam)

#### xyplot can work if one by one in  Fam ####
    plot3.data<-subset(plot.data,Fam==1)
    heading=paste("Fam_",1)
    xyplot(rank ~ ca, data=plot3.data, groups=Spacing,
type="o",main=heading)


###### the following code for control flow doesn't work ####
for (i in 1:3){
    plot3.data<-subset(plot.data,Fam==i)
    heading=paste("Fam_",i)
    xyplot(rank ~ ca, data=plot3.data, groups=Spacing,
type="o",main=heading)
}

############ data format ######
data format of plot.data shows as folow:
 Fam Fam2 Spacing ca rank  1 Fam_70001 S2 1 14  1 Fam_70001 S2 2 46  1
Fam_70001 S2 3 49  1 Fam_70001 S2 4 47  1 Fam_70001 S2 5 54  1 Fam_70001 S3
1 18  1 Fam_70001 S3 2 38  1 Fam_70001 S3 3 34  1 Fam_70001 S3 4 27  1
Fam_70001 S3 5 29  2 Fam_70002 S2 1 8  2 Fam_70002 S2 2 12  2 Fam_70002 S2 3
25  2 Fam_70002 S2 4 8  2 Fam_70002 S2 5 13  2 Fam_70002 S3 1 26  2
Fam_70002 S3 2 22  2 Fam_70002 S3 3 19  2 Fam_70002 S3 4 14  2 Fam_70002 S3
5 7

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to