Displaying 2 results from an estimated 2 matches for "mean_dfx_if_yis0".
2011 Jul 27
1
how to replace values in x by means in subgroups created in ... (not loops)
...ply (not very fast)
x <-c(0 ,1,2,3,4,5,6,7,8,NA,NA,1 ,1 ,NA,2 ,2)
y <-c(0 ,0,0,1,0,0,0,1,1,1 ,NA,0 ,0 ,0 ,0 ,1)
Must_be<-c(1 ,1,1,3,5,5,5,7,8,NA,NA,1.5,1 ,NA,1.5,2)
(df<-as.data.frame(cbind(x,y)) )
# I have traied many bad colusions based on cumsum, pmin, pmax, ...
(mean_dfx_if_yIs0<-y*cumsum(x*y)/(cumsum(y)*y) )
# how to do this?
# thans for any advice
# E
[[alternative HTML version deleted]]
2011 Jul 28
0
_: how to replace values in x by means in subgroups created in ...(not loops)
...1 ,1 ,NA,2 ,2)
>> y <-c(0 ,0,0,1,0,0,0,1,1,1 ,NA,0 ,0 ,0 ,0 ,1)
>> Must_be<-c(1 ,1,1,3,5,5,5,7,8,NA,NA,1.5,1 ,NA,1.5,2)
>>
>> (df<-as.data.frame(cbind(x,y)) )
>>
>> # I have traied many bad colusions based on cumsum, pmin, pmax, ...
>> (mean_dfx_if_yIs0<-y*cumsum(x*y)/(cumsum(y)*y) )
>>
>> # how to do this?
>> # thans for any advice
>> # E
[[alternative HTML version deleted]]