Skip to content
Back to formatted view

Raw Message

Message-ID: <f8e6ff050612311033j7255e9d1u803a7597b5ce685@mail.gmail.com>
Date: 2006-12-31T18:33:11Z
From: Hadley Wickham
Subject: tabulate: switching columns and rows
In-Reply-To: <s5980d3c.098@niloufer.xen.net>

Hi Ricardo,

> Please, is there any way of controlling factors in row/columns when using ftable/xtabs? As far as I can see, the last cross-clasifing variable in the formula will appear in columns. The previous ones, in rows. For instance, is it possible to make  tension and replicate appear in columns?
>
> ftable(xtabs(breaks ~ wool + tension + replicate, data = warpbreaks))
>
> After some years using SAS proc tabulate I am afraid I don't get the point with R and cross-tabulation :-(

You might want to have a look at the reshape package,
http://had.co.nz/reshape, which provides a more general and flexible
framework for reshaping data in R.

The version of warpbreaks I have doesn't have the replicate variable,
so unfortunately I can't provide you with example code for this case.
However, you should be able to figure it out for your data using the
documentation available on the website.

Regards,

Hadley