[R] Collapsing Categorical Variables

Ko-Kang Kevin Wang k.wang at auckland.ac.nz
Fri Feb 27 00:51:02 CET 2004


> -----Original Message-----
> From: Phil Spector [mailto:spector at stat.Berkeley.EDU] 
> 
> How about something like:
> 
> tstreet = table(STREET)
> collapsestreets = names(tstreet[tstreet <= 15])
> STREET[STREET %in% collapsestreets] = 'OTHER'

Thanks a lot!

This is exactly what I want.  I had a feeling my way to use a for() loop
was rather silly....;D

Kevin

--------------------------------------------
Ko-Kang Kevin Wang, MSc(Hon)
Statistics Workshops Co-ordinator
Student Learning Centre
University of Auckland
New Zealand




More information about the R-help mailing list