Message-ID: <f8e6ff050911241905x3bb1ff5es888136c5c4d39409@mail.gmail.com>
Date: 2009-11-25T03:05:19Z
From: Hadley Wickham
Subject: reshape question
In-Reply-To: <73CC881F-FBEE-48B1-BAFA-71D6463A1403@comcast.net>
> I don't really understand what you want and the example solution throws away
> quite a lot of data, so consider this alternative:
>
> data.out2 <- read.table(textConnection("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"), header=T,
> stringsAsFactors=F)
>
Or
library(reshape)
df <- melt(data.out2, na.rm = T, id = "id")
df <- cbind(df, colsplit(df$variable, "\\.", c("var", "time")))
cast(df, id + time ~ var)
See http://had.co.nz/reshape for more details.
Hadley
--
http://had.co.nz/