I have a huge college dataset and I want to be able to find which colleges appear more than once in the dataset. How would I go about doing this? The variable college is a factor. If I just do table(college) it is impossible to find where there are repetitions. Any help would be greatly appreciated! Lynna [[alternative HTML version deleted]]
Here you have an example: > colleges <- factor( c("a", "a", "b", "c", "c" )) > colleges [1] a a b c c Levels: a b c > table( colleges ) colleges a b c 2 1 2 > colleges.count <- table( colleges )[colleges] > colleges.count colleges a a b c c 2 2 1 2 2 > which( colleges.count > 1 ) a a c c 1 2 4 5 Kristen Mark wrote:> I have a huge college dataset and I want to be able to find which colleges appear more than once in the dataset. How would I go about doing this? The variable college is a factor. If I just do table(college) it is impossible to find where there are repetitions. Any help would be greatly appreciated! > > Lynna > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
college=c("Columbia","Columbia","Harvard","Harvard","NYU") unique(college) table(college) unique(college)[table(college)>1] HTH Daniel ------------------------- cuncta stricte discussurus ------------------------- -----Urspr?ngliche Nachricht----- Von: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] Im Auftrag von Kristen Mark Gesendet: Sunday, December 06, 2009 6:41 PM An: r-help at r-project.org Betreff: [R] help with repeated values I have a huge college dataset and I want to be able to find which colleges appear more than once in the dataset. How would I go about doing this? The variable college is a factor. If I just do table(college) it is impossible to find where there are repetitions. Any help would be greatly appreciated! Lynna [[alternative HTML version deleted]] ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.