Hi eg. your data frame has 35 rows and 6 columns
a<-sample(1:6, 35, replace=T) b<-1:35 vec<-rep(0,35*6) vec[a+6*(b-1)]<-1 This shall do the replacement your.d.f[matrix(vec,35,6, byrow=T)==1] <- 0 But I am not sure if it is quicker than a loop. HTH Petr On 18 Jan 2006 at 2:35, Kenneth Cabrera wrote: Date sent: Wed, 18 Jan 2006 02:35:35 -0500 From: Kenneth Cabrera <[EMAIL PROTECTED]> To: r-help@stat.math.ethz.ch Subject: [R] Data frame index? > Hi, R users: > > I have a data.frame (not a matrix), I got a vector with the same > length as the number of records (rows) of the data frame, and each > element of that vector is the column number (in a specific range of > columns) of the corresponding record that I must set to zero. > > How can I do this without a "for" loop? > > Thank you for your help. > > Kenneth > > Petr Pikal [EMAIL PROTECTED] ______________________________________________ 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