A ddply solution is
dat.out <- ddply(dat, .(time), transform, slope = scale(slope))
but this is not faster than the loop, and slower than the ave() solution:
> system.time(
+ for (i in 1:3) {
+mat <- dat[dat$time==i, ]
+outi <- data.frame(mat$time, mat$id, slope=scale(mat$slope))
+if
On Thu, Aug 26, 2010 at 4:33 PM, Bos, Roger wrote:
> I created a small example to show something that I do a lot of. "scale"
> data by month and return a data.frame with the output. "id" represents
> repeated observations over "time" and I want to scale the "slope"
> variable. The "out" variabl
On Aug 26, 2010, at 3:40 PM, Marc Schwartz wrote:
> On Aug 26, 2010, at 3:33 PM, Bos, Roger wrote:
>
>> I created a small example to show something that I do a lot of. "scale"
>> data by month and return a data.frame with the output. "id" represents
>> repeated observations over "time" and I wa
On Aug 26, 2010, at 3:33 PM, Bos, Roger wrote:
> I created a small example to show something that I do a lot of. "scale"
> data by month and return a data.frame with the output. "id" represents
> repeated observations over "time" and I want to scale the "slope"
> variable. The "out" variable sh
I created a small example to show something that I do a lot of. "scale"
data by month and return a data.frame with the output. "id" represents
repeated observations over "time" and I want to scale the "slope"
variable. The "out" variable shows the output I want. My for..loop
does the job but is
5 matches
Mail list logo