[R] ungrouping grouped data

Michael Friendly friendly at yorku.ca
Thu Sep 25 19:14:06 CEST 2003


I'm sure this is probably simple, but I can't find an answer...
I have a data frame (Galton's data on heights of parents and children), 
in grouped form,

parent child frequency
73.5 72.2 1
73.5 73.2 3
72.5 68.2 1
72.5 69.2 2
72.5 70.2 1
72.5 71.2 2
72.5 72.2 7
72.5 73.2 2
72.5 74.2 4
71.5 65.2 1
71.5 66.2 3
71.5 67.2 4
71.5 68.2 3
71.5 69.2 5
71.5 70.2 10
...

and need the ungrouped equivalent, where each input observation
appears the number of times represented by its frequency.  In SAS
this would be

data galton2;
    set galton;
    do i=1 to frequency;
       output;
    end;

I can replicate this in R, but surely there must be an easier way.
(In APL2 it would be frequency\[1]galton)

thanks,
-Michael

-- 
Michael Friendly     Email: friendly at yorku.ca 
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA




More information about the R-help mailing list