Thank you Phil, your method worked great!
Again, I was about to write back and add some facts -- all of the columns
need to be 'character'... when I tried my and Jonathan's solutions with
columns that were factors, I got errors.
Here's what happened when I tried to use the 'dcast' method on my ac
Another way, using just base R is
reshape(df,idvar='y',timevar='x',v.names='z',direction='wide')
y z.A z.B z.C
1 D a b c
4 E d e f
7 F g h i
- Phil Spector
Statistical Computing Facility
Hi Jonathan,
Thank you very much! I was about to recall this after I found this
discussion (https://stat.ethz.ch/pipermail/r-help/2008-June/164440.html),
but I think your solution is more tidy.
Thank you very much!
Matt
On Wed, Dec 8, 2010 at 8:33 PM, Jonathan Christensen wrote:
> Matt,
>
> li
Matt,
library(reshape2)
wide.df <- dcast(df, y ~ x)
Works great for me.
Jonathan
On Wed, Dec 8, 2010 at 7:26 PM, Matthew Pettis wrote:
> Hi,
>
> I was wondering if there is an easy way that I am missing for turning a long
> dataframe into a wide one. Below is sample code that will make what
Hi,
I was wondering if there is an easy way that I am missing for turning a long
dataframe into a wide one. Below is sample code that will make what I have
and, in comments, the form of what I want:
# Have: dataframe like 'df'
df <- expand.grid( x=LETTERS[1:3], y=LETTERS[4:6])
df$z <- lett
5 matches
Mail list logo