[R] Cross-tabulation Question

John Kane jrkrideau at yahoo.ca
Mon Sep 29 16:15:28 CEST 2008


?aggregate or have a look at the reshape package.


--- On Mon, 9/29/08, Shubha Vishwanath Karanth <shubhak at ambaresearch.com> wrote:

> From: Shubha Vishwanath Karanth <shubhak at ambaresearch.com>
> Subject: [R] Cross-tabulation Question
> To: r-help at stat.math.ethz.ch
> Received: Monday, September 29, 2008, 4:54 AM
> Hi R,
> 
>  
> 
> This is a cross tabulation question. Suppose that,
> 
>  
> 
> > d=read.table("clipboard",header=F)
> 
>  
> 
> > d
> 
>   V1  V2    V3
> 
>   A  One Apple
> 
>   A  One  Cake
> 
>   A  One  Cake
> 
>   B  One Apple
> 
>   B  One Apple
> 
>   B  One Apple
> 
>  
> 
> > table(d$V2,d$V3)
> 
>      
> 
>         Apple Cake
> 
>   One     4    2
> 
>  
> 
>  
> 
> But, I don't want the count to be like the above. Here,
> it is counting
> the number of rows in that particular category. What I need
> is in each
> category, the count of unique V1's. So, my output
> should look like,
> 
>  
> 
>         Apple Cake
> 
>   One     2    1
> 
>  
> 
>  
> 
> Any ideas please...
> 
>  
> 
> Thanks, Shubha
> 
>  
> 
> This e-mail may contain confidential and/or privileged
> i...{{dropped:13}}
> 
> ______________________________________________
> 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.


      __________________________________________________________________
[[elided Yahoo spam]]



More information about the R-help mailing list