[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

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:


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?



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