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

Konrad Hoppe konradhoppe at hotmail.de
Tue Jan 12 10:46:53 CET 2010


Hi,

maybe this is what you're looking for:

dates <- c(as.Date("08/30/03", format="%m/%d/%y"),
		as.Date("01/01/03", format="%m/%d/%y"),
		as.Date("01/01/02", format="%m/%d/%y"),
		as.Date("02/01/03", format="%m/%d/%y"))
entries <- c(1,2,3,4)
dat <- data.frame(dates,entries)
dat[order(dat$dates),]


regards
--
Konrad Hoppe
http://www.konrad-hoppe.com/

-----Ursprüngliche Nachricht-----
Von: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] Im Auftrag von
Samuel.Meichtry at bkw-fmb.ch
Gesendet: Dienstag, 12. Januar 2010 10:04
An: r-sig-finance at stat.math.ethz.ch
Betreff: [R-SIG-Finance] Sorting Data.Frames after merge?

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

-- 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