[Rd] apply on logical data frame together with all (PR#6560 )

Liaw, Andy andy_liaw at merck.com
Mon Feb 9 19:13:37 MET 2004


Wrap your data frame in data.matrix() and you should be fine; e.g.,

  apply(data.matrix(df), 1, all)

Don't think this qualifies as bug...

Andy

> From: roland.puntaier at chello.at
> 
> 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)
> 
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-devel
> 
> 


------------------------------------------------------------------------------
Notice:  This e-mail message, together with any attachments,...{{dropped}}



More information about the R-devel mailing list