[R] Binning or grouping data

Ronggui Huang ronggui.huang at gmail.com
Thu Jun 4 12:13:00 CEST 2009


Personally, I prefer the recode() in package of car.

Ronggui

2009/6/4 Philipp Pagel <p.pagel at wzw.tum.de>:
>> I'm attempting to "group" or "bin" data together in order to analyze them as
>> a combined group rather than as discrete set.  I'll provide a simple example
>> of the data for illustrative purposes.
>>
>> Patient ID  |  Charges   |    Age  |   Race
>> 1              |  100          |    0     |   Black
>> 2              |  500          |    3     |   White
>> 3              |  200          |    5     |   Hispanic
>> 4              |   90           |    7     |   Asian
>> 5              |    400        |   10     |   Hispanic
>> 6              |    500        |   16     |   Black
>>
>> I'm trying to create three age categories--"0 to 4", "5 to 11" and "12 to
>> 17"--and analyze their "Charges" by their "Race."  How do I go abouts to
>> doing this?
>
> cut() or split() are probably the functions you are looking for.
>
> cu
>        Philipp
>
> --
> Dr. Philipp Pagel
> Lehrstuhl für Genomorientierte Bioinformatik
> Technische Universität München
> Wissenschaftszentrum Weihenstephan
> 85350 Freising, Germany
> http://webclu.bio.wzw.tum.de/~pagel/
>
> ______________________________________________
> 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.
>



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html




More information about the R-help mailing list