Xin <jasonshi510 <at> hotmail.com> writes: > > y<-data[,7] > x<-data[,3] > > I want to know the mean of y if corresponding x=1. > Try this: mean(data[data[,3]==1,data[,7]) You can also look at ?subset.