it works! Thanks!
On Tue, May 21, 2013 at 1:24 PM, Sarah Goslee <sarah.gos...@gmail.com>wrote: > You can use rep() to create the Date column, and data.frame() to combine > it. > > For your simple example, > > newdata <- data.frame(dat, Date=rep(1:3, each=2)) > > On Tue, May 21, 2013 at 4:16 PM, Ye Lin <ye...@lbl.gov> wrote: > > I want to add identifier column (Date) to a time series data frame. I > want > > to name the "Date" column be from 1 to 30 every 1440 rows. > > > > Say I have a data like this (I simply my actual data here): > > > > $dat > > > > ID Var > > 1 1 > > 2 4 > > 3 6 > > 4 7 > > 5 7 > > 6 8 > > > > How can I add identifier column (Date) from 1 to 3 every 2 rows and have > > output like this: > > > > ID Var Date > > 1 1 1 > > 2 4 1 > > 3 6 2 > > 4 7 2 > > 5 7 3 > > 6 8 3 > > > -- > Sarah Goslee > http://www.functionaldiversity.org > [[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.