[R] Crosstab from sql dump

Alan Gibson alan.gibson at gmail.com
Sun Dec 31 00:51:57 CET 2006


thanks for all the tips.

using 'unstack(read.table('/tmp/codes', header=TRUE))' gets me

  user1 user2
1   100   100
2   200   200
3   300   300

where /tmp/codes contains

code name
100 user1
200 user1
300 user1
100 user2
200 user2
300 user2

so unstack is exactly what i was looking for. for the record, it is
probably a good idea to specify which column is values and which is
group indicator like 'unstack(read.table('/tmp/crap', header=TRUE),
"code ~ name")' in case your columns are in a different order.

alan

On 12/30/06, Dieter Menne <dieter.menne at menne-biomed.de> wrote:
> Alan Gibson <alan.gibson <at> gmail.com> writes:
>
> > Im looking for a simple function to produce a crosstab from a dumped
> > sql query result.
>
>
> xtabs in stats is a simple solution, but package reshape is much more flexible
> and comes with a good introduction.pdf.
>
> Dieter
>
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list