[R] Cannot be coerced to logical?

Tova Fuller suprtova at ucla.edu
Mon Oct 30 03:34:04 CET 2006


Hello all,

So I am having a puzzling problem.  I am working with a 534 x 1065  
data frame entitled LocalMaxExpBlue.COR which is completely full of  
logical values "TRUE" and "FALSE."  However, when I attempt to  
manipulate this data frame, R does not recognize it as logical.   
Strangely enough, it will identify individual columns (but not rows)  
as logical.  It will also identify all of the individual elements of  
each row as logical.  Here are some examples:

 > is.logical(LocalMaxExpBlue.COR)
[1] FALSE

 > is.logical(LocalMaxExpBlue.COR[,1])
[1] TRUE

 > is.logical(LocalMaxExpBlue.COR[1,])
[1] FALSE

# If we look at the first five values of the first row, we notice  
that each value is indeed logical:
 > LocalMaxExpBlue.COR[1,c(1:5)]
      X1    X2    X3    X4    X5
1 FALSE FALSE FALSE FALSE FALSE

# However, it does not recognize this!:
 > is.logical(LocalMaxExpBlue.COR[1,c(1:5)])
[1] FALSE

# It does recognize that individual values of each row are logical:
 > is.logical(LocalMaxExpBlue.COR[1,1])
[1] TRUE
 > is.logical(LocalMaxExpBlue.COR[1,2])
[1] TRUE
# etc.

Thank you in advance for your help.  Perhaps I have made some small  
obvious mistake.



More information about the R-help mailing list