Hello,
I was used to count how many times every factor is found the following
way :
(assuming 'vect' is a vector of factors)
tapply(vect,vect,length)
but recently I experienced weird results with this
In fact, my command line was
tapply(ORGMORE[[1]][vect],ORGMORE[[1]][vect],length)
where
- 'vect' is a vector of indices
- 'ORGMORE[[1]]' is a slightly long vector of factors
In managed to get correct results using
tapply(paste(ORGMORE[[1]][vect]),paste(ORGMORE[[1]][vect]),length)
I am not sure the reason is the presence of NA values in ORGMORE[[1]],
or
the size of it because I tried unsuccessfully to reproduce this with an
another session
of R and a short vector having NA values.
....and 'vect' is the result of a previous tapply call.
In my opinion, I do not get what I want the good-safe way...
Any hints ?
Laurent
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._