Re: [R] simple data transformation question

2010-03-02 Thread Albert-Jan Roskam
. ~~ --- On Tue, 3/2/10, Henrique Dallazuanna wrote: From: Henrique Dallazuanna Subject: Re: [R] simple data transformation question To: "Albert-Jan Roskam" Cc: r-help@r-project.org Date: Tuesday, March 2, 2010, 2:45 PM Try this: reshape(cbind(id = as.numeric(dtf$var), dtf, time =  wit

Re: [R] simple data transformation question

2010-03-02 Thread Henrique Dallazuanna
Try this: reshape(cbind(id = as.numeric(dtf$var), dtf, time = with(dtf, ave(value, var, FUN = seq))), timevar="time", direction="wide") Or: xtabs(value ~ var + ave(value, var, FUN = seq), data = dtf) On Tue, Mar 2, 2010 at 9:40 AM, Albert-Jan Roskam wrote: > Hi all, > I have a (hopefully) si

[R] simple data transformation question

2010-03-02 Thread Albert-Jan Roskam
Hi all, I have a (hopefully) simple newbie-level question.   # I have data like this: dtf <- data.frame(read.table(textConnection("var  value   company  9887.1   company  91117.0   blaah  91.1   etc  11   etc  97111"), header=TRUE))   # I would like to have output like this (the index number may