Skip to content
Prev 327531 / 398502 Next

Duplicated function with conditional statement

On Jul 26, 2013, at 2:06 PM, David Winsemius wrote:

            
So this delivers the specified output:

tt$rown <- rownames(tt)
as.numeric ( apply(tt, 1, function(x) { 
     x['product'] %in% tt[ rownames(tt) < x['rown'] & tt$response == "buy", "product"]  } ) )

# [1] 0 0 0 0 0 1 1 0 1 0
David Winsemius
Alameda, CA, USA