Wouldn't sum(which(CONDITION)) add up the index numbers for all the
rows where the CONDITION was true? Please elaborate what I should do.
For the record, none of my data has NA, 1, and T/F in it. I was trying
to say that the same thing happens whether you look at vars with
T/F/NA using ==TRUE and vars with integers/NA using ==integer. Don't
call my variables wack.
Andy
On Sat, 20 Nov 2004 16:50:28 -0500 (EST), Olivia Lau
<olau(a)fas.harvard.edu> wrote:
I think you want sum(which()), not nrow(). And no
variable should have
NA, 1, and TRUE/FALSE in it. That's whack. You need to clean your data.
On Sat, 20 Nov 2004, Andrew Eggers wrote:
I discovered an unpleasant R feature and wondered
if anyone could
suggest a workaround or show me where I am going wrong.
I have been using logical statements and nrow() to extract the number
of observations that have certain characteristics.
for example, I thought the following statement
nrow(X[X[,1]==TRUE,])
would tell me how many rows of X had TRUE in the first column.
But it turns out that R considers anything that is TRUE or 1 _or_ NA
as TRUE. (The same is true when you say nrow(X[X[,1]==1,]).)
Can anyone tell me how to deal with this? Can anyone explain why R
would count NA as TRUE?
Andy
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l
_______________________________________________
gov2001-l mailing list
gov2001-l(a)lists.fas.harvard.edu
http://lists.fas.harvard.edu/mailman/listinfo/gov2001-l