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

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jan 12 13:40:21 CET 2010


This code is not reproducible since there are variables used that are
not supplied.  See last line to every message on r-help.

The zoo package can store time series with arbitrary index class
provided it supports certain methods and merge such series while
keeping them sorted automatically.  See the three vignettes that come
with the package and ?merge.zoo


On Tue, Jan 12, 2010 at 4:03 AM,  <Samuel.Meichtry at bkw-fmb.ch> wrote:
> 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
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>



More information about the R-SIG-Finance mailing list