Hi All,

I am wanting to convert a data.frame from a wide format to a long format
(with >1 variable) and am having difficulties. Any help is appreciated!

#current wide format
> head(data.out2)
     id   rater.1 n.1   rater.2 n.2   rater.3 n.3   rater.4 n.4
11   11 0.1183333  79        NA  NA        NA  NA        NA  NA
114 114 0.2478709 113        NA  NA        NA  NA        NA  NA
12   12 0.3130655  54 0.3668242  54        NA  NA        NA  NA
121 121 0.2400000 331        NA  NA        NA  NA        NA  NA
122 122 0.3004164  25 0.1046278  25 0.2424871  25 0.2796937  25
125 125 0.1634865 190        NA  NA        NA  NA        NA  NA

#This is close but I would like the 'n' column to remain and for the '.1' to
drop off

> data.out3<-reshape(data.out2,varying=list(names(data.out2)[-1]),
+  idvar='id',direction='long')
> head(data.out3)
       id time   rater.1
11.1   11    1 0.1183333
114.1 114    1 0.2478709
12.1   12    1 0.3130655
121.1 121    1 0.2400000
122.1 122    1 0.3004164
125.1 125    1 0.1634865

Ideally I would like the columns to be set up in this manner:

id    time    rater     n


Thanks,

AC

        [[alternative HTML version deleted]]

______________________________________________
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