You've been told how to do what you ask. But I'm not convinced that you really want to do what you asked.
It might be better to do whatever you want with the data leaving it all in one object. There are many ways of doing that, the 'by' function is one of them. On 11/11/2011 20:24, Francesca wrote:
Dear Contributors I would like to perform this operation using a loop, instead of repeating the same operation many times. The numbers from 1 to 4 related to different groups that are in the database and for which I have the same data. x<-c(1,3,7) datiP1<- datiP[datiP$city ==1,x]; datiP2<- datiP[datiP$city ==2,x]; datiP3<- datiP[datiP$city ==3,x] datiP4<- datiP[datiP$city ==4,x];
-- Patrick Burns pbu...@pburns.seanet.com twitter: @portfolioprobe http://www.portfolioprobe.com/blog http://www.burns-stat.com (home of 'Some hints for the R beginner' and 'The R Inferno') ______________________________________________ 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.