Re: [R] How to preserve date format while aggregating

2008-09-09 Thread Prof Brian Ripley
This is completely wrong: min _is_ defined for date-times: min(.leap.seconds) [1] 1972-07-01 01:00:00 BST Please do study the posting guide and do your homework before posting: you seem unaware of what the POSIXct class is, so ?DateTimeClasses is one place you need to start. And

[R] How to preserve date format while aggregating

2008-09-08 Thread Erich Studerus
Hi I have a dataframe in which some subjects appear in more than one row. I want to extract the subject-rows which have the minimum date per subject. I tried the following aggregate function. attach(dataframe.xy) aggregate(Date,list(SubjectID),min) Unfortunately, the format of the Date-column

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread jim holtman
Try changing the 'class' of the numeric result back to Date: x - as.Date('2008-09-08') x [1] 2008-09-08 y - as.numeric(x) y [1] 14130 str(y) num 14130 class(y) - Date y [1] 2008-09-08 str(y) Class 'Date' num 14130 On Mon, Sep 8, 2008 at 6:38 AM, Erich Studerus [EMAIL PROTECTED]

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Erich Studerus
the rows with minimum/earliest date per subject. Erich -Ursprüngliche Nachricht- Von: jim holtman [mailto:[EMAIL PROTECTED] Gesendet: Montag, 8. September 2008 14:24 An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Try changing

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread jim holtman
-Ursprüngliche Nachricht- Von: jim holtman [mailto:[EMAIL PROTECTED] Gesendet: Montag, 8. September 2008 14:24 An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Try changing the 'class' of the numeric result back to Date: x - as.Date

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Dr Eberhard Lisse
-Ursprüngliche Nachricht- Von: jim holtman [mailto:[EMAIL PROTECTED] Gesendet: Montag, 8. September 2008 14:24 An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Try changing the 'class' of the numeric result back to Date: x - as.Date

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Erich Studerus
:43 An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Erich, how does the data look, when it comes from SQL? And why not extract the data with SQL directly, so you don't have this issue in the first place? el on 9/8/08 3:15 PM Erich

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Prof Brian Ripley
An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Erich, how does the data look, when it comes from SQL? And why not extract the data with SQL directly, so you don't have this issue in the first place? el on 9/8/08 3:15 PM Erich Studerus

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Gabor Grothendieck
with minimum/earliest date per subject. Erich -Ursprüngliche Nachricht- Von: jim holtman [mailto:[EMAIL PROTECTED] Gesendet: Montag, 8. September 2008 14:24 An: Erich Studerus Cc: r-help@r-project.org Betreff: Re: [R] How to preserve date format while aggregating Try changing the 'class

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Adam D. I. Kramer
Hi Erich, Since min() is defined for numbers and not dates, the problem is in the min() function. min() is converting from date format to number format. Your best bet is to make this conversion explicit...such that it is reversable. So, convert the date into UTC, then UTC to seconds since

Re: [R] How to preserve date format while aggregating

2008-09-08 Thread Gabor Grothendieck
min does work for POSIXct and Date too: ct - ISOdatetime(2008, 1, 1:10, 0, 0, 0) min(ct) [1] 2008-01-01 EST min(as.Date(ct)) [1] 2008-01-01 On Mon, Sep 8, 2008 at 6:57 PM, Adam D. I. Kramer [EMAIL PROTECTED] wrote: Hi Erich, Since min() is defined for numbers and not dates, the problem