[R] Merge data frames but with a twist.
    Tony Breyal 
    tony.breyal at googlemail.com
       
    Thu Aug 27 13:04:30 CEST 2009
    
    
  
Dear all,
Question: How to merge two data frames such that new column are added
in a particular way?
I'm not actually sure how to best articulate my question to be honest,
so i hope showing you what I want to achieve will communicate my
question better.
Lets say I have two data frames:
> DF1 <- data.frame(cbind(Show=c('Firefly', 'Red Dwarf'), Measure=1:2, Datetime=c('08/26/2009 9:30 AM', '08/26/2009 9:30 AM')))
> DF2 <- data.frame(cbind(Show=c('Firefly', 'Red Dwarf'), Measure=3:4, Datetime=c('08/26/2009 11:30 AM', '08/26/2009 11:30 AM')))
And then let us merge these:
> DF3 <- merge(DF1, DF2, all=TRUE)
       Show         Measure            Datetime
1     Firefly         1                      08/26/2009 9:30 AM
2     Firefly         3                      08/26/2009 11:30 AM
3     Red Dwarf   2                      08/26/2009 9:30 AM
4     Red Dwarf   4                      08/26/2009 11:30 AM
What i would like to do is merge the data frames such that i end up
with the following:
Show           08/26/2009 9:30 AM        08/26/2009 11:30 AM
Firefly          1                                    3
Red Dwarf    2                                    4
my reason for doing this is so that i can plot a time series somehow.
I hope the formating stays when i post this message and that what i'm
trying to do is easy to understand. Thank you kindly for any help in
advance.
Tony
    
    
More information about the R-help
mailing list