[R] Making a factor with common levels ...
j.logsdon@lancaster.ac.uk
j.logsdon at lancaster.ac.uk
Thu Sep 27 17:37:53 CEST 2001
This is doing my head in. Staying away from R for too long is bad for the
health!
I have two vectors of character names where there may be repetition and
from which I want to form two factors with the same levels but only if
there are more than N instances of each name in each vector.
I can get the list of common names quite easily, using:
nn<-sort(unique(c(levels(n1)[table(n1)>N],levels(n0)[table(n0)>N])))
Some of the factor levels may be empty for one of the factors but the same
level must be present in the other.
Is there a simple way to extract nn0 and nn1 so that the pairs remain
correctly aligned and each list has at least N cases of each name? Or do
I have to jump into my steamroller and do a couple of loops?
TIA
John
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list