Re: [R] adding an additional column for preserving uniqueness

2015-01-28 Thread Chel Hee Lee
I like the way presented by William Dunlap in the previous post. You may also try this: > dat1$item <- Reduce(c,lapply(table(dat1$Date), seq_len)) > dat2$item <- Reduce(c,lapply(table(dat2$Date), seq_len)) > dat1 Date ConcAve item 1 2009-07-08 71 2 2009-08-26 11 3

Re: [R] adding an additional column for preserving uniqueness

2015-01-28 Thread William Dunlap
> with(dat1, ave(integer(length(Date)), Date, FUN=seq_along)) [1] 1 1 2 1 1 2 1 2 1 2 1 Bill Dunlap TIBCO Software wdunlap tibco.com On Wed, Jan 28, 2015 at 4:54 PM, Morway, Eric wrote: > The two datasets below are excerpts from much larger datasets. Note that > there are duplicate dates in

[R] adding an additional column for preserving uniqueness

2015-01-28 Thread Morway, Eric
The two datasets below are excerpts from much larger datasets. Note that there are duplicate dates in both dat1 and dat2, e.g., "2009-10-14". dat1 <- read.table(textConnection("Date ConcAve 2009-07-08 7 2009-08-26 1 2009-08-26 2 2009-09-15 2 2009-10-14 2 2009-10-14