[R] weird apply() behavior

Heikki Kaskelma heikki.kaskelma at nbl.fi
Tue Aug 30 03:13:17 CEST 2011


"array chip":
>Hi, I had a weird results from using apply().

Consider:

y<-data.frame(list(a=c(1,NA), b=c('2k','0')))
do.call(args=y,
            Vectorize(v=c("a","b"),
                             function(a,b) if(is.na(z<-b=="2k" & a==1)) 0
else z+0))

Heikki Kaskelma
Munkkiniemi



More information about the R-help mailing list