Is this what you want:

> x
  id agency offer month product
1  1      a     L   gen    star
2  2      b     M   feb  meteor
3  3      c     N   gen    moon
4  4      d     O march    moon
> require(reshape2)
> dcast(x, agency + offer ~ product, fun = length)
Using product as value column: use value.var to override.
  agency offer meteor moon star
1      a     L      0    0    1
2      b     M      1    0    0
3      c     N      0    1    0
4      d     O      0    1    0
>



Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.


On Fri, Feb 28, 2014 at 6:56 AM, lara.palandra <lara.palan...@libero.it>wrote:

> hi..i would create a pivot table in R and i would create two levels of
> columns. I'll try to explain better. I have a table so done:
>
> id   agency           offer     month      product
>
> 1       a                L      gen             star
> 2       b                M      feb             meteor
> 3       c                N      gen             moon
> 4       d                O      march   moon
> ..      ..              ...     ....            ....
>
> i'd like to aggregate this table in this way:
> <http://r.789695.n4.nabble.com/file/n4685993/pivot.png>
>
> in the table there is id count.
>
> help me!!
> Lara
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/pivot-table-tp4685993.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to