To all of you who answered me: Thank you so much!
Each approach taught me something new and I really appreciate your help!
Best regards,
Dana Sevak
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the pos
> This does it more or less your way:
>
> ds <- split(df, df$Name)
> ds <- lapply(ds, function(x){x$Index <- seq_along(x[,1]); x})
> df2 <- unsplit(ds, df$Name)
> tapply(df2$X1, df2[,c("Name", "Index")], function(x) x)
>
> athough there may exist much easier ways ...
Here's one way with the plyr a
Try this:
DF$Index <- ave(1:nrow(DF), DF$Name, FUN = seq_along)
reshape(DF[-3], dir = "wide", idvar = "Name", timevar = "Index")
Also see the reshape package for another similar facility.
On Wed, May 13, 2009 at 2:02 AM, Dana Sevak wrote:
>
> Dear R Helpers,
>
> I have trouble applying reShap
one way is the following:
df.index <- df
df.index$Index <- ave(seq_along(df$Name), df$Name, FUN = seq_along)
df.index
df2 <- reshape(df.index[c("Name", "Index", "X1")], timevar = "Index",
idvar = "Name", direction = "wide")
df2
I hope it helps.
Best,
Dimitris
Dana Sevak wrote:
Dear R Hel
Dana Sevak wrote:
Dear R Helpers,
I have trouble applying reShape and reshape although I read the documentation
and several posts, so I would very much appreciate your help on the two points
below.
I have a dataframe
df = data.frame(Name=c("a", "a", "a", "b", "b", "c"), X1=c("12", "13", "1
5 matches
Mail list logo