[Rd] apply on logical data frame together with all (PR#6560)
roland.puntaier at chello.at
roland.puntaier at chello.at
Mon Feb 9 18:13:29 MET 2004
Full_Name: Roland Puntaier
Version: 1.8.1
OS: Windows XP
Submission from: (NULL) (62.99.238.78)
I have a data frame with some columns being logical.
I wanted to calculate a column that is an AND combination of the other logical
columns.
I tried to use
apply(df,1,all)
It did not work because of the implicit string conversion.
So I made the functions
All<-function(...) all(as.logical(...))#because all cannot be used with apply
Any<-function(...) any(as.logical(...))#because any cannot be used with apply
Now
apply(df,1,All)
seemed to work,
but produced some NAs where there was no reason for them.
I debugged apply and found that some logical values are transformed to " TRUE"
instead of "TRUE". I did not follow that up closer. Instead I worked around it
by doing the string conversion myself and then call apply(dfc,1,All)
More information about the R-devel
mailing list