Thanks a lot - these solutions are much more elegant than my own:
new.data-merge(mydata[mydata$group %in%
levels(mydata$group)[1],],reference,by=mydate,all.x=T,all.y=T)
new.data[[group]][is.na(new.data[[group]])]-levels(mydata$group)[1]
new.data[[values]][is.na(new.data[[values]])]-0
# Continue
Hello!
I have my data frame mydata (below) and data frame reference -
that contains all the dates I would like to be present in the final
data frame.
I am trying to merge them so that the the result data frame contains
all 8 dates in both subgroups (i.e., Group1 should have 8 rows and
Group2 too).
To clarify just in case, here is the result I am trying to get:
mydate group values
12/29/2008 Group1 0.453466522
1/5/2009Group1 NA
1/12/2009 Group1 0.416548943
1/19/2009 Group1 2.066275155
1/26/2009 Group1 2.037729638
2/2/2009Group1 -0.598040483
On Mon, Apr 4, 2011 at 1:09 PM, Dimitri Liakhovitski
dimitri.liakhovit...@gmail.com wrote:
Hello!
I have my data frame mydata (below) and data frame reference -
that contains all the dates I would like to be present in the final
data frame.
I am trying to merge them so that the the result
Try this:
merge(mydata, cbind(reference, group = rep(unique(mydata$group), each
= nrow(reference))), all = TRUE)
On Mon, Apr 4, 2011 at 2:24 PM, Dimitri Liakhovitski
dimitri.liakhovit...@gmail.com wrote:
To clarify just in case, here is the result I am trying to get:
mydate group values
5 matches
Mail list logo