[R] Re : Frequency count
Andrew Robinson
andrewr at uidaho.edu
Tue Jan 4 23:59:46 CET 2005
Try table(), aggregate(), or tapply(), using length() in the last two
functions.
I hope that this helps,
Andrew
On Wed, Jan 05, 2005 at 11:36:07AM +1300, ssim at lic.co.nz wrote:
> Dear list,
>
> I have a dataset as follow and I would like to count the frequencies for
> the combination of the two variables (f1 and f2) for each id. I know it is
> should be straight forward, but I just don't know how to do it in R. Here
> is the SAS code I will use to get the output I want :
>
> proc means nway;
> class id f1 f2;
> var flag
> output out=temp;
>
>
> Dataset:
> id f1 f2 flag
> 798 1 2 1
> 777 0 2 1
> 798 2 2 1
> 777 0 2 1
> 777 1 1 1
>
> Output:
> Id=798
> 1-2 1
> 2-2 1
>
> Id=777
> 0-2 2
> 1-1 1
> ___________________________________________________________________________
> This message, including attachments, is confidential. If you...{{dropped}}
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
--
Andrew Robinson Ph: 208 885 7115
Department of Forest Resources Fa: 208 885 6226
University of Idaho E : andrewr at uidaho.edu
PO Box 441133 W : http://www.uidaho.edu/~andrewr
Moscow ID 83843 Or: http://www.biometrics.uidaho.edu
No statement above necessarily represents my employer's opinion.
More information about the R-help
mailing list