[Reposting with changed example and font spec removed]
Hi,

I want to take the dataframe df generated below and reshape the data
with column names being w, x, y, and the different levels of z.  The
values under the different levels of z are the corresponding values of
r.  I've tried reshape and cast, and I can't seem to find the right
combination.  Any help is appreciated,

Matt
---------------------------------
   # Generate data
w <- c("a","b")
x <- c("c","d")
y <- c("e","f")
z <- c("g","h")
df <- expand.grid(w=w,x=x,y=y,z=z)
df$r <- rnorm(16,mean=0,sd=1)

-------------------------------------
Wanted output:

w   x   y   g      h
-   -   -   -      -
a   c   e   0.1    0.2
a   c   f   -0.4   0.32
a   d   e   ...    ....
...

______________________________________________
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