From: alex diaz <celebridades_at_megamail.pt>

Date: Tue 28 Jun 2005 - 04:49:35 EST

dat$c<-t1+t2+t3+t4+t5+t6

Email Enviado utilizando o serviço MegaMail

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 Received on Tue Jun 28 04:56:45 2005

Date: Tue 28 Jun 2005 - 04:49:35 EST

dear list:

I need help to achieve a simpler code to complete a
task I'm performing.

here is an example:

dat<-expand.grid(a=seq(1,5),b=seq(1000,1005))

I want to add a new column dat$c in that:

t1<-ifelse(dat$a==1&dat$b==1001,1001,0) t2<-ifelse(dat$a==2&dat$b==1002,1001,0) t3<-ifelse(dat$a==3&dat$b==1003,1001,0) t4<-ifelse(dat$a==1&dat$b==1002,1002,0) t5<-ifelse(dat$a==2&dat$b==1003,1002,0) t6<-ifelse(dat$a==1&dat$b==1003,1003,0)

dat$c<-t1+t2+t3+t4+t5+t6

My real data frame is much larger... I hope someone can help me with this.

thanks for your help

- diaz

Email Enviado utilizando o serviço MegaMail

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 Received on Tue Jun 28 04:56:45 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:33:03 EST
*