From andy_liaw at merck.com  Mon Feb  9 19:14:26 2004
From: andy_liaw at merck.com (andy_liaw@merck.com)
Date: Mon Feb  9 19:15:07 2004
Subject: [Rd] apply on logical data frame together with all (PR#6560
Message-ID: <20040209181426.0B10AEAEC@slim.kubism.ku.dk>

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@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@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}}


[Rd] apply on logical data frame together with all (PR#6560
andy_liaw@merck.com