[R] reshape question

Alexandre Swarowsky aleswar at yahoo.com.br
Tue Nov 18 03:07:27 CET 2008


Hi,

It's probably a simple issue but I'm struggling with that. I'll use the
example shown in the help page.

head(Indometh)
wide <- reshape(Indometh, v.names="conc", idvar="Subject",
                timevar="time", direction="wide")
head(wide)
reshape(wide, idvar="Subject", varying=list(2:12),
        v.names="conc", direction="long")

but, in my case I'll like the "time" column be filled with the row names with the exception of "Subject", of course, instead of 1,2,3, and so on.

I want something like that:

    Subject  time         conc
1.1        1    conc.0.25 1.50
2.1        2    conc.0.25 2.03
3.1        3    conc.0.25 2.72

Thanks in advance,

Alex
-- 
Alexandre Swarowsky
Soils and Biogeochemistry Graduate Group
University of California at Davis
One Shields Avenue 
Davis CA 95618
Office: (530)752-4131
cell: (530)574-3028



More information about the R-help mailing list