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
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
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
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
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
(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
),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
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
-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
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
10 matches
Mail list logo