Re: [R] pattern of panel waves using R

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Fri, 18 Mar 2011 10:00:53 -0400

On Mar 17, 2011, at 11:40 PM, Sebastián Daza wrote:

> Hi everyone,
>
> Is there any command to identify the pattern of responses of a
> database with this format:
>
> year id
> 2008 1
> 2009 1
> 2008 2
> 2009 2
> 2008 3
> 2009 3
> 2008 4
> 2009 4
> 2010 4

Two methods assuming this is in a a data.frmae named `dat` and you want cross-tabulation:

tapply(dat$year, dat$id, length)

`xtabs` offers a more flexible method

xtabs(year ~ id, data=dat)

-- 
David.

>
>
> I just need the frequency of the patterns grouped by id:
>
> 2008 2009 2010 = 80
I don't understand what format this might be specifying. If you offer an example you should also specify the correct output from that example rather than the output from a larger example whose content you make the reader guess at. I cannot see any connection between the numbers 80, 30, and 10 with the example above, nor cann is see a connection with the set 2008, 2009, and 2010 with anything other than the set of objects associated with id==4. So its possible that the first step in your desired process might be the split function. > split(dat, dat$id) $`1` year id 1 2008 1 2 2009 1 $`2` year id 3 2008 2 4 2009 2 $`3` year id 5 2008 3 6 2009 3 $`4` year id 7 2008 4 8 2009 4 9 2010 4 )
> 2009 2010 = 30
> 2008 2009 = 10
> and so on....
>
> Thank you in advance!
>
> --
David Winsemius, MD West Hartford, CT ______________________________________________ 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.
Received on Fri 18 Mar 2011 - 14:05:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 18 Mar 2011 - 14:15:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive