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