[R-SIG-Finance] Sorting Data.Frames after merge?

Samuel.Meichtry at bkw-fmb.ch Samuel.Meichtry at bkw-fmb.ch
Tue Jan 12 10:03:40 CET 2010


Hi Mailinglist members,

I've got a question concerning the sorting a data.frame in Gnu R by a specific column. I have calculated deviations and means of a electricity consumption timeserie and would like to roll it out for the next 4 years.

After merging two data.frames by weeknumber (week) and weekday over several years, I get a unsorted data.frame, meaning that it is not in the correct date order. Therefore I would like to sort it by TimeStamp again.

Thanks in advance.


#DataFrame No.1
rf <- data.frame(
        Week=tmWeek[s:e],
        Weekday=tmWeekday[s:e],
        Mean=smMean[s:e],    
        Quantile05=smQuant05[s:e],
        Quantile95=smQuant95[s:e]
)

#DataFrame No.2
md <- data.frame(
    TimeStamp = tmp.d, 
    Week = tmp.week,
    Weekday = tmp.weekday  
)

#Merging of the two DataFrames
kdf <- merge(md,rf,by=intersect(names(md),names(rf)))

____________________________________________
BKW FMB Energie AG
Energy Trading
Samuel Meichtry
Analyst Energy Trading
Tel +41 31 330 53 99
Fax +41 31 330 56 16
e-mail samuel.meichtry at bkw-fmb.ch



More information about the R-SIG-Finance mailing list