Just follow this example from example(reshape):
reshape(wide, idvar="Subject", varying=list(names(wide)[2:12]),
v.names="conc", direction="long")
like this:
long <- reshape(dd, direction = "long", varying
list(names(dd)[5:7]), idvar = "v",
v.names = "x", times = paste("value", 1:3,
sep=""))
long[order(long$date),]
Its even simpler if you use the reshape package:
library(reshape)
long <- melt(dd, id = 1:4)
long[order(long$date),]
On 4/6/06, Richard van Wingerden <ros110 at gmail.com>
wrote:> Hi,
>
> I have a data fram like this:
>
> date column1 column2 column3 value1 value2 value3
> 1-1 A B C 10 5 2
> 2-1 A B D 5 2 0
> 3-1 A B E 17 10 7
>
> How can I reshape it to:
>
> date column1 column2 column3 v x
> 1-1 A B C value1 10
> 1-1 A B C value2 5
> 1-1 A B C value3 2
> 2-1 A B D value1 5
> 2-1 A B D value2 2
> 2-1 A B D value3 0
> 3-1 A B E value1 17
> 3-1 A B E value2 10
> 3-1 A B E value3 7
>
> Thx!
>
> Regards,
>
> Richard
>
> ______________________________________________
> 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
>