Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
E  TRUE  TRUE FALSE FALSE TRUE  TRUE  TRUE FALSE #z  TRUE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE  TRUE  TRUE FALSE #u  TRUE  TRUE FALSE FALSE    NA    NA  TRUE FALSE    NA TRUE FALSE FALSE  TRUE   A.K. - Original Message - From: Camilo Mora To: arun Cc: R help Sent: W

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
msum(c(0,abs(diff(x),cumsum dat2New[rowSums(is.na(dat2New))!=0 & rowSums(is.na(dat2New))!=ncol(dat2New),]<-NA  dat2New #   a  b  c  d  e  f  g  h  i  j  k  l  m #w  0  0  0  0  0  1  2  3  4  0  0  0  0 #x NA NA NA NA NA NA NA NA NA NA NA NA NA #y  1  2  3  4  5  0  0  1  2  0  0 

Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
umsum dat2New[rowSums(is.na(dat2New))!=0 & rowSums(is.na(dat2New))!=ncol(dat2New),]<-NA  dat2New #   a  b  c  d  e  f  g  h  i  j  k  l  m #w  0  0  0  0  0  1  2  3  4  0  0  0  0 #x NA NA NA NA NA NA NA NA NA NA NA NA NA #y  1  2  3  4  5  0  0  1  2  0  0  0  1 #z  0  0  0  0  1  0  0  0  1  0  0

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
ttp://www.soc.hawaii.edu/mora/ Quoting arun : HI, Just a correction: : dat2[]<-t(apply(!dat1,1,function(x) unlist(lapply(split(x,cumsum(c(0,abs(diff(x),cumsum  #should also work A.K. - Original Message - From: arun To: Camilo Mora Cc: R help Sent: Wednesday, March

Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
RUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE TRUE TRUE TRUE FALSE A.K. - Original Message - From: Camilo Mora To: arun Cc: R help Sent: Wednesday, March 27, 2013 3:27 PM Subject: Re: [R] conditional Dataframe filling Dear Arun, Thank you very  much for your help with this.I did not kn

Re: [R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
(x),cumsum))))  #should also work A.K. - Original Message - From: arun To: Camilo Mora Cc: R help Sent: Wednesday, March 27, 2013 9:09 AM Subject: Re: [R] conditional Dataframe filling Hi, You could try: dat1<- read.table(text=" a    b    c    d TRUE  TRUE  TRUE  TRUE

Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
),cumsum  dat2 #  a b c d #1 0 0 0 0 #2 1 2 3 0 #3 1 0 1 2 A.K. - Original Message - From: Camilo Mora To: r-help@r-project.org Cc: Sent: Wednesday, March 27, 2013 4:31 AM Subject: [R] conditional Dataframe filling Hi everyone: This may be trivial but I just have not been abl

Re: [R] conditional Dataframe filling

2013-03-27 Thread arun
dat2 #  a b c d #1 0 0 0 0 #2 1 2 3 0 #3 1 0 1 2 A.K. - Original Message - From: Camilo Mora To: r-help@r-project.org Cc: Sent: Wednesday, March 27, 2013 4:31 AM Subject: [R] conditional Dataframe filling Hi everyone: This may be trivial but I just have not been able to figure i

Re: [R] conditional Dataframe filling

2013-03-27 Thread Blaser Nello
-boun...@r-project.org] On Behalf Of Camilo Mora Sent: Mittwoch, 27. März 2013 09:32 To: r-help@r-project.org Subject: [R] conditional Dataframe filling Hi everyone: This may be trivial but I just have not been able to figure it out. Imagine the following dataframe: a b c d TRUE T

[R] conditional Dataframe filling

2013-03-27 Thread Camilo Mora
Hi everyone: This may be trivial but I just have not been able to figure it out. Imagine the following dataframe: a b c d TRUE TRUE TRUE TRUE FALSE FALSE FALSE TRUE FALSE TRUE FALSE FALSE I would like to create a new dataframe, in which TRUE gets 0 but if false then add 1 to