Re: [R] date calculation

2010-10-29 Thread Ben Bolker
Shi, Tao shidaxia at yahoo.com writes: Could someone explain to me why the following result is not a integer? difftime(strptime(24NOV2004, format=%d%b%Y), strptime(13MAY2004, format=%d%b%Y), units=days) Time difference of 195.0417 days Presumably because this goes across a

[R] Help: From Excel date to R-date!

2010-10-21 Thread Amy Young-King
Hi all, I am really new to dealing with Excel date and time formats to be used in R. I have an Excel exported data matrix in TXT format. One column, labeled DATE, is of the following format examples: 1/8/98 1:00 1/8/98 23:00 to mean that the observation was made on 1st of August 1998 at 1AM

Re: [R] Help: From Excel date to R-date!

2010-10-21 Thread Prof Brian Ripley
If those are the only formats and the dates are in the current timezone ... dates - c(1/8/98 1:00, 1/8/98 23:00) as.POSIXct(dates, format = %d/%m/%y %H:%M) [1] 1998-08-01 01:00:00 1998-08-01 23:00:00 As for how to handle such a time series in R, it depends if it is a regular or irregular

Re: [R] Help: From Excel date to R-date!

2010-10-21 Thread Gabor Grothendieck
On Thu, Oct 21, 2010 at 1:31 PM, Amy Young-King amy.young.k...@gmail.com wrote: Hi all, I am really new to dealing with Excel date and time formats to be used in R. I have an Excel exported data matrix in TXT format. One column, labeled DATE, is of the following format examples: 1/8/98

[R] Date Time Objects

2010-10-13 Thread dpender
I am trying to convert an array from numeric values back to date and time format. The code I have used is as follows; for (i in 0:(length(DateTime3)-1)) { DateTime3[i] - (strptime(start, %m/%d/%Y %H:%M)+ i*interval) where start - [1] 1/1/1981 00:00 However the created array

Re: [R] Date Time Objects

2010-10-13 Thread Henrique Dallazuanna
Try this: sapply(0:(length(DateTime3)-1), function(i)as.character(strptime(start, %m/%d/%Y %H:%M) + i * interval)) On Wed, Oct 13, 2010 at 8:51 AM, dpender d.pen...@civil.gla.ac.uk wrote: I am trying to convert an array from numeric values back to date and time format. The code I have

Re: [R] Date Time Objects

2010-10-13 Thread dpender
Thanks Henrique, Do you have any idea why the first entry doesn't have the time as the start specified is 1/1/1981 00:00? Is it something to do with being at midnight? Doug -- View this message in context: http://r.789695.n4.nabble.com/Date-Time-Objects-tp2993524p2993640.html Sent from the

Re: [R] Date Time Objects

2010-10-13 Thread Henrique Dallazuanna
Try this: sapply(0::(length(DateTime3)-1), function(i)format(strptime(start, %m/%d/%Y %H:%M) + i * interval, %Y-%m-%d %H:%M:%S)) On Wed, Oct 13, 2010 at 10:16 AM, dpender d.pen...@civil.gla.ac.uk wrote: Thanks Henrique, Do you have any idea why the first entry doesn't have the time as the

Re: [R] Date Time Objects

2010-10-13 Thread dpender
Perfect. Thanks -- View this message in context: http://r.789695.n4.nabble.com/Date-Time-Objects-tp2993524p2993663.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Date/Time format

2010-09-27 Thread Costas
Hello, Is it possible to instruct (permanently) R to write on csv (and read from csv) time series, where the time stamp has a particular format: say: -mm-dd i.e., as in format(Sys.Date(), %Y-%m-%d) Many thanks in advance, Costas __

Re: [R] Date issues

2010-09-19 Thread Gabor Grothendieck
On Sun, Sep 19, 2010 at 1:31 AM, Santosh Srinivas santosh.srini...@gmail.com wrote: I tried this and it works too (For most part) strangely for certain dates (20090831) it is giving NA ... FnO_Data$Date[m:l]  [1] 20090828 20090828 20090828 20090828 20090828 20090828 20090828 20090828

[R] Date issues

2010-09-18 Thread Santosh Srinivas
Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the

Re: [R] Date issues

2010-09-18 Thread David Winsemius
On Sep 18, 2010, at 11:25 AM, Santosh Srinivas wrote: Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA ?sasDate as.Date does not take numeric arguments. Try: as.Date(as.character(tDate),

Re: [R] Date issues

2010-09-18 Thread Marc Schwartz
On Sep 18, 2010, at 10:25 AM, Santosh Srinivas wrote: Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA What version of R are you running? What is the output of: str(FnO_Data$Date) and

Re: [R] Date issues

2010-09-18 Thread Gabor Grothendieck
On Sat, Sep 18, 2010 at 11:25 AM, Santosh Srinivas santosh.srini...@gmail.com wrote: Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA Do you have zoo loaded? If you do then a minimal

Re: [R] Date issues

2010-09-18 Thread Santosh Srinivas
Thanks. -Original Message- From: David Winsemius [mailto:dwinsem...@comcast.net] Sent: 18 September 2010 21:07 To: Santosh Srinivas Cc: r-help@r-project.org Subject: Re: [R] Date issues On Sep 18, 2010, at 11:25 AM, Santosh Srinivas wrote: Strangely this is not working ... what am I

Re: [R] Date issues

2010-09-18 Thread David Winsemius
On Sep 18, 2010, at 11:36 AM, David Winsemius wrote: On Sep 18, 2010, at 11:25 AM, Santosh Srinivas wrote: Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA ?sasDate as.Date does not take

Re: [R] Date issues

2010-09-18 Thread Santosh Srinivas
- From: Gabor Grothendieck [mailto:ggrothendi...@gmail.com] Sent: 18 September 2010 21:27 To: Santosh Srinivas Cc: r-help@r-project.org Subject: Re: [R] Date issues On Sat, Sep 18, 2010 at 11:25 AM, Santosh Srinivas santosh.srini...@gmail.com wrote: Strangely this is not working ... what am I

Re: [R] Date issues

2010-09-18 Thread Henrik Bengtsson
Subject: Re: [R] Date issues On Sat, Sep 18, 2010 at 11:25 AM, Santosh Srinivas santosh.srini...@gmail.com wrote: Strangely this is not working ... what am I doing wrong here? tDate - FnO_Data$Date[1] tDate [1] 20090101 as.Date(c(tDate),format=%Y%m%d) [1] NA Do you have zoo loaded?  If you do

[R] date conversion

2010-09-03 Thread André de Boer
Hello, I have a dataframe with data such as: dat$BEGINDATUM[3] [1] 13-09-2007 dat$BEGINDATUM[4] [1] 01-11-2007 class(dat$BEGINDATUM[3]) [1] factor Now I need to make calculation with these dates. But I get these result: as.date(as.character(dat$BEGINDATUM[3])) [1] NA

Re: [R] date conversion

2010-09-03 Thread Joshua Wiley
Hi, I think you just need to add the format = argument. Does this help? x - factor(01-11-2007) as.character(x) [1] 01-11-2007 as.Date(as.character(x), format = %d-%m-%Y) [1] 2007-11-01 Cheers, Josh On Fri, Sep 3, 2010 at 2:11 PM, André de Boer rnie...@gmail.com wrote: Hello, I have a

[R] date

2010-09-02 Thread Dunia Scheid
Hello all, I've 2 strings that representing the start and end values of a date and time. For example, time1 - c(21/04/2005,23/05/2005,11/04/2005) time2 - c(15/07/2009, 03/06/2008, 15/10/2005) as.difftime(time1,time2) Time differences in secs [1] NA NA NA attr(,tzone) [1] How can i calculate the

Re: [R] date

2010-09-02 Thread Ista Zahn
Hi Dunia, You need to convert the character strings to Dates. time1 - as.Date(c(21/04/2005,23/05/2005,11/04/2005), %d/%m/%Y) time2 - as.Date(c(15/07/2009, 03/06/2008, 15/10/2005), %d/%m/%Y) time2-time1 Best, Ista On Thu, Sep 2, 2010 at 10:32 AM, Dunia Scheid dunia.sch...@gmail.com wrote:

Re: [R] date

2010-09-02 Thread Linlin Yan
try to use difftime() instead of as.difftime(). On Thu, Sep 2, 2010 at 10:32 PM, Dunia Scheid dunia.sch...@gmail.com wrote: Hello all, I've 2 strings that representing the start and end values of a date and time. For example, time1 - c(21/04/2005,23/05/2005,11/04/2005) time2 -

Re: [R] Date Inconsistencies? Buglets?

2010-08-21 Thread Jim Lemon
On 08/21/2010 12:35 AM, ivo welch wrote: ... (PS: Is there an easier way to tell R that I want a whole lot more tick marks and/or labels than what it gives me by default?) Hi Ivo, I haven't been able to find a way to make the axis function print more tick mark labels than it wants to. That's

Re: [R] Date Inconsistencies? Buglets?

2010-08-21 Thread ivo welch
This would make a nice feature for the next R release---a parameter that overrides the default choice for the number of ticks or labels on the axes. since it has to be calculated already, this should not be hard---spoken by someone without knowledge of the innards, of course. /iaw On Sat, Aug

[R] Date Inconsistencies? Buglets?

2010-08-20 Thread ivo welch
The treatment of dates seems to be a little inconsistent in R 2.11.1 (2010-05-31): [1] The choice of origins? as.integer(as.Date(1970-01-01)) works and assumes as origin 1970-01-01. However, as.Date(1) does not work. It requires an origin (as.Date(1, origin=1970-01-01)). If we set a

Re: [R] Date Inconsistencies? Buglets?

2010-08-20 Thread Gabor Grothendieck
On Fri, Aug 20, 2010 at 10:35 AM, ivo welch ivo.we...@gmail.com wrote: The treatment of dates seems to be a little inconsistent in R 2.11.1 (2010-05-31): [1] The choice of origins?   as.integer(as.Date(1970-01-01)) works and assumes as origin 1970-01-01.  However,   as.Date(1) The zoo

Re: [R] Date Inconsistencies? Buglets?

2010-08-20 Thread Gavin Simpson
On Fri, 2010-08-20 at 10:35 -0400, ivo welch wrote: The treatment of dates seems to be a little inconsistent in R 2.11.1 (2010-05-31): snip / [2] How do dates on axes work? plot( c(as.Date(1:20, origin=1970-01-01)), 1:20 ) axis( side=3, c(as.Date(1:20, origin=1970-01-01))) The

[R] Date conversion

2010-08-04 Thread Steven Kang
Hi all, I am trying to convert all the dates (all days that are not Friday) in data frame into dates to next Friday. The following works but the result is returned as vector rather than the original class. It would be greatly apprecited if you could provide any solution to this problem. Many

Re: [R] Date conversion

2010-08-04 Thread Gabor Grothendieck
On Wed, Aug 4, 2010 at 8:33 PM, Steven Kang stochastick...@gmail.com wrote: Hi all, I am trying to convert all the dates (all days that are not Friday) in data frame into dates to next Friday. The following works but the result is returned as vector rather than the original class. It

[R] date from weeknumber

2010-07-20 Thread H Rao
Hi, Is there a function to get the last(or first) day of the week, given the week number of the year? For eg, week number for 7/20 is 29 as obtained by format(Sys.Date(),%U), is there a function which returns 7/25 - the last day of week # 29 TIA, Rao. [[alternative HTML version

Re: [R] date from weeknumber

2010-07-20 Thread David Winsemius
On Jul 20, 2010, at 6:37 PM, H Rao wrote: Hi, Is there a function to get the last(or first) day of the week, given the week number of the year? For eg, week number for 7/20 is 29 as obtained by format(Sys.Date(),%U), is there a function which returns 7/25 - the last day of week # 29

Re: [R] date from weeknumber

2010-07-20 Thread Gabor Grothendieck
On Tue, Jul 20, 2010 at 6:37 PM, H Rao hydsd...@gmail.com wrote: Hi, Is there a function to get the last(or first) day of the week, given the week number of the year? For eg, week number for 7/20 is 29 as obtained by format(Sys.Date(),%U), is there a function which returns 7/25 - the last

Re: [R] Date conversion

2010-06-11 Thread Felipe Carrillo
jwiley.ps...@gmail.com To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch Sent: Thu, June 10, 2010 1:18:27 PM Subject: Re: [R] Date conversion Hello Felipe, Is this what you want? format(as.Date(3/10/10, format=%m/%d/%y), %B %d, %Y) Josh On Thu, Jun 10, 2010 at 8:29

[R] Date conversion

2010-06-10 Thread Felipe Carrillo
Hi: Can't find a way to convert from shortDate to LongDate format. I got: 3/10/10 that I want to convert to March 10, 2010. I am using: \documentclass[11pt]{article} \usepackage{longtable,verbatim} \usepackage{ctable} \usepackage{datetime} \title{my title} \begin{document}   % Convert date

Re: [R] Date conversion

2010-06-10 Thread Joshua Wiley
Hello Felipe, Is this what you want? format(as.Date(3/10/10, format=%m/%d/%y), %B %d, %Y) Josh On Thu, Jun 10, 2010 at 8:29 AM, Felipe Carrillo mazatlanmex...@yahoo.com wrote: Hi: Can't find a way to convert from shortDate to LongDate format. I got: 3/10/10 that I want to convert to March

Re: [R] Date conversion issue

2010-03-18 Thread ManInMoon
Thanks - that works -- View this message in context: http://n4.nabble.com/Date-conversion-issue-tp1596548p1597627.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

[R] Date conversion issue

2010-03-17 Thread ManInMoon
I am parsing dates as follows: z[1:10,1:3] V1 V2 V3 10 03/02/09 22:20:51.274 2 100 03/02/09 22:28:18.801 3 200 03/02/09 22:33:33.762 4 300 03/02/09 22:40:21.826 5 400 03/02/09 22:41:38.361 6 500 03/02/09 22:42:50.882 7 600 03/02/09 22:45:19.885 8 700 03/02/09

Re: [R] Date conversion issue

2010-03-17 Thread ManInMoon
Sorry -- View this message in context: http://n4.nabble.com/Date-conversion-issue-tp1596548p1596880.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE

Re: [R] Date conversion issue

2010-03-17 Thread Henrique Dallazuanna
Use %y indeed of %Y. On Wed, Mar 17, 2010 at 12:00 PM, ManInMoon xmoon2...@googlemail.com wrote: I am parsing dates as follows: z[1:10,1:3]    V1       V2           V3 1    0 03/02/09 22:20:51.274 2  100 03/02/09 22:28:18.801 3  200 03/02/09 22:33:33.762 4  300 03/02/09 22:40:21.826 5  

[R] Date conversion problem

2010-03-04 Thread Newbie19_02
Hi All, I have a character data.frame that contains character columns and date columns. I've manage to convert some of my character columns to a date format using as.Date(x, format=%m/%d/%y). An example of one of my dates is PROCHIDtDeath icdcucd date_admission1 date_admission_2

Re: [R] Date conversion problem

2010-03-04 Thread Don MacQueen
as.Date('17/02/2005','%d/%m/%Y') [1] 2005-02-17 (Read the documentation more carefully to distinguish between %y and %Y; I guess you tried lots of combinations but never tried the correct one, so just be more careful at matching what your data is with the format string you create.)

[R] Date label lost while inverting y axis.

2010-02-19 Thread Jeremie Smaga
Good morning, I am currently displaying a time series with the time on the Y axis, and the values on the X axis. The problem is that I wanted to reverse the Y axis (that is, to have the latest date the closest to the X axis). So I looked for a way to do this on this mailing list and I found a

Re: [R] Date label lost while inverting y axis.

2010-02-19 Thread David Winsemius
On Feb 19, 2010, at 2:20 AM, Jeremie Smaga wrote: Good morning, I am currently displaying a time series with the time on the Y axis, and the values on the X axis. The problem is that I wanted to reverse the Y axis (that is, to have the latest date the closest to the X axis). So I looked

[R] date and time functions

2010-01-27 Thread Robert Kalicki
Dear R community I would like to perform some statistical analysis on a data set containing the following items: date, time, index of observation and various covariates. The date and time are originally extracted in the following format: dd.mm. and hh:mm:ss respectively. R and more

Re: [R] date and time functions

2010-01-27 Thread Gabor Grothendieck
Read the article in R News 4/1. 2010/1/27 Robert Kalicki robert.kali...@mph.unibe.ch: Dear R community I would like to perform some statistical analysis on a data set containing the following items: date, time, index of observation and various covariates. The date and time are originally

[R] date conversion not as i would have expected

2009-10-21 Thread clair.crossup...@googlemail.com
Good day, i imported some data into R from Excel. By using the edit() function, this is what one of the dates looks like in R: x - structure(1254351600, class = c(POSIXt, POSIXct), tzone = ) [1] 2009-10-01 BST However, when i do the following, the date changes: as.Date(x, formate=%Y-%m-%d )

Re: [R] date conversion not as i would have expected

2009-10-21 Thread Duncan Mackay
Hi This is on WinXP with regional settings as EST (we are now on DST but I run EST) R2.9.2 x - structure(1254351600, class = c(POSIXt, POSIXct), tzone = ) x [1] 2009-10-01 09:00:00 EST as.POSIXlt(x) [1] 2009-10-01 09:00:00 EST as.Date(x, formate=%Y-%m-%d ) [1] 2009-09-30 I had a similar

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
Thank you all who replied, I will try out these ideas later today. David Esp -- View this message in context: http://www.nabble.com/Date-Time-Stamp-input-method-for-user-specific-formats-tp25757018p25763935.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread Gabor Grothendieck
See below. On Mon, Oct 5, 2009 at 6:50 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: Try this.  First we read a line at a time into L except for the header.  Then we use strapply to match on the given pattern.  It passes the backreferences (the portions within parentheses in the

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
esp wrote: For the function as defined above using 'sapply' spot[,1] 01/09/2009 01/09/2009 00:00:01 01/09/2009 00:00:02 01/09/2009 00:00:03 1251759600 1251759601 1251759602 1251759603 This was unexpected - it seems to have displayed the

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-06 Thread esp
Another solution, as a fix to my original algorithm, was found by a colleague (Matthew Roberts). While he claims not too much for its elegance, it does seem to work. This fix is based on the use of the 'pmax' function. This function is a variant of the 'max' (maximum) function to return a

[R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread esp
Date-Time-Stamp input method to correctly interpret user-specific formats:coding is 90% there - based on exmple at http://tolstoy.newcastle.edu.au/R/help/05/02/12003.html ...anyone got the last 10% please? CONTEXT: Data is received where one of the columns is a datetimestamp. At midnight,

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread Don MacQueen
Off the top of my head, I think you're working to hard at this. I would read in the timestamp column as a character string. Then, find those where the string length is too short [using nchar()], append 00:00:00 to those [using paste()], and then convert to POSIXt [using as.POSIXct()]. No

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread David Winsemius
On Oct 5, 2009, at 5:14 PM, esp wrote: Date-Time-Stamp input method to correctly interpret user-specific formats:coding is 90% there - based on exmple at http://tolstoy.newcastle.edu.au/R/help/05/02/12003.html ...anyone got the last 10% please? CONTEXT: Data is received where one of the

Re: [R] Date-Time-Stamp input method for user-specific formats

2009-10-05 Thread Gabor Grothendieck
Try this. First we read a line at a time into L except for the header. Then we use strapply to match on the given pattern. It passes the backreferences (the portions within parentheses in the pattern) to the function (defined via a formula) whose implicit arguments are x, y and z. That

[R] Date formats in as.Date

2009-09-24 Thread Worik R
I have trouble with this: as.Date(Sep-1981, format=%b-%Y) Returns NA From documentation for strftime '%b' Abbreviated month name in the current locale. (Also matches full name on input.) '%Y' Year with century. What am I doing wrong? cheers Worik [[alternative HTML

Re: [R] Date formats in as.Date

2009-09-24 Thread Jim Porzak
Worik, You need a day! as in: as.Date(1-Sep-1981, format=%d-%b-%Y) ## first of the month HTH, Jim Porzak Ancestry.com San Francisco, CA www.linkedin.com/in/jimporzak use R! Group SF: www.meetup.com/R-Users/ On Thu, Sep 24, 2009 at 4:15 PM, Worik R wor...@gmail.com wrote: I have trouble

Re: [R] Date formats in as.Date

2009-09-24 Thread Gabor Grothendieck
Try this: library(zoo) as.yearmon(Sep-1981, %b-%Y) [1] Sep 1981 as.Date(as.yearmon(Sep-1981, %b-%Y)) [1] 1981-09-01 as.Date(paste(1, Sep-1981), %d %b-%Y) [1] 1981-09-01 On Thu, Sep 24, 2009 at 7:15 PM, Worik R wor...@gmail.com wrote: I have trouble with this: as.Date(Sep-1981,

[R] Date/Time to date time

2009-09-20 Thread Mark Knecht
Hi, Can strptime (or some other function) help me turn the following column of a data.frame into two new columns, one as date and the other as time, preserving the AM/PM value? Thanks, Mark B ENTRY DATE 1 3/23/2009 6:30:00 AM 2 3/23/2009 6:30:00 AM 3 3/23/2009 6:39:00 AM 4

Re: [R] Date/Time to date time

2009-09-20 Thread jim holtman
Here is one way to do it. Not sure why you want columns with either date or time since you already have them. This will create a POSIXct object you can use for processing and then two character columns with date and time. Exactly what are you going to do with the data. str(x) 'data.frame':

Re: [R] Date/Time to date time

2009-09-20 Thread Gabor Grothendieck
Note that your explanation refers to strptime but the code uses strftime which accounts for the error. Try this: Lines - ENTRY DATE + 3/23/2009 6:30:00 AM + 3/23/2009 6:30:00 AM + 3/23/2009 6:39:00 AM + 3/23/2009 6:39:00 AM + 3/23/2009 6:48:00 AM + 3/23/2009 6:48:00 AM + 3/23/2009 7:00:00 AM

Re: [R] Date/Time to date time

2009-09-20 Thread Mark Knecht
Thanks Gabor, I did try to use dput but it wasn't cooperating and wanted to send FAR too much data. Your method works well for me but as I look at it I don't understand the use of double brackets - DF[[1]] - why do you do that? Anyway, thanks for the fast reponses from you and Jim. Both

Re: [R] Date/Time to date time

2009-09-20 Thread Gabor Grothendieck
On Sun, Sep 20, 2009 at 4:52 PM, Mark Knecht markkne...@gmail.com wrote: Thanks Gabor,   I did try to use dput but it wasn't cooperating and wanted to send FAR too much data. dput(head(x, 10))   Your method works well for me but as I look at it I don't understand the use of double brackets

Re: [R] Date/Time to date time

2009-09-20 Thread Mark Knecht
On Sun, Sep 20, 2009 at 1:55 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Sun, Sep 20, 2009 at 4:52 PM, Mark Knecht markkne...@gmail.com wrote: Thanks Gabor,   I did try to use dput but it wasn't cooperating and wanted to send FAR too much data. dput(head(x, 10)) As I said, I

Re: [R] Date format in plot

2009-09-02 Thread swertie
As suggested in the article R News 4/1, I used as.Date(as.character(Phenology_VE$Date), %Y-%m-%d), however this function returns me only NA values as.Date(as.character(Phenology_VE$Date), %Y-%m-%d) [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [26] NA NA NA NA

Re: [R] Date format in plot

2009-09-02 Thread jim holtman
A reproducible example would help. What is Phenology_VE$Date? This works as.Date(2009-09-01, %Y-%m-%d) [1] 2009-09-01 Is this the date you wanted: as.Date(39936, origin='1900-2-1') [1] 2009-06-05 On Wed, Sep 2, 2009 at 2:09 AM, swertiev_coudr...@voila.fr wrote: As suggested in the

[R] Date format in plot

2009-09-01 Thread swertie
Hello, I plot the abundance of a species in relation to the date. To have the date as a continous variable I put it in the format standard in excel (f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like to have 06.05. I tried to use as.Date as suggested in some discussion

Re: [R] Date format in plot

2009-09-01 Thread Erik Iverson
To: r-help@r-project.org Subject: [R] Date format in plot Hello, I plot the abundance of a species in relation to the date. To have the date as a continous variable I put it in the format standard in excel (f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like to have 06.05. I

Re: [R] Date format in plot

2009-09-01 Thread David Winsemius
On Sep 1, 2009, at 1:58 PM, swertie wrote: Hello, I plot the abundance of a species in relation to the date. To have the date as a continous variable I put it in the format standard in excel (f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like to have 06.05. I

Re: [R] Date format in plot

2009-09-01 Thread David Winsemius
Subject: [R] Date format in plot Hello, I plot the abundance of a species in relation to the date. To have the date as a continous variable I put it in the format standard in excel (f.ex. 39939 means 06.05.2009). R uses 39939 on the x axis, but I would like to have 06.05. I tried to use as.Date

Re: [R] Date format in plot

2009-09-01 Thread Gabor Grothendieck
See R News 4/1. The article on dates there discusses how they work and discusses Excel's dates as well. On Tue, Sep 1, 2009 at 1:58 PM, swertiev_coudr...@voila.fr wrote: Hello, I plot the abundance of a species in relation to the date. To have the date as a continous variable I put it in the

[R] Date conversions

2009-07-11 Thread Mark Knecht
Hi all, I'm having a little bit of trouble with some date conversions and am hoping someone can help me out. Thanks in advance. OK, I have two sources of data that provide date info in a csv file differently. I've attached a small zipped file with two text files that illustrate both. (Is it

Re: [R] Date conversions

2009-07-11 Thread Mark Knecht
On Sat, Jul 11, 2009 at 10:20 AM, Gabor Grothendieckggrothendi...@gmail.com wrote: No attachment appeared. I don't think the list allows zip files as attachments. Try plain text. On Sat, Jul 11, 2009 at 1:10 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi all,   I'm having a little bit of

Re: [R] Date conversions

2009-07-11 Thread Gabor Grothendieck
No attachment appeared. I don't think the list allows zip files as attachments. Try plain text. On Sat, Jul 11, 2009 at 1:10 PM, Mark Knechtmarkkne...@gmail.com wrote: Hi all,   I'm having a little bit of trouble with some date conversions and am hoping someone can help me out. Thanks in

Re: [R] Date conversions

2009-07-11 Thread Gabor Grothendieck
You want %Y, not %y. You might also want to look at the zoo package: library(zoo) z - read.zoo(Date1.txt, header = TRUE, sep = ,, format = %m/%d/%Y) or using chron: library(zoo) library(chron) z - read.zoo(Date1.txt, header = TRUE, sep = ,, FUN = as.chron) There are three vignettes that come

Re: [R] Date conversions

2009-07-11 Thread Mark Knecht
On Sat, Jul 11, 2009 at 12:05 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: You want %Y, not %y. You might also want to look at the zoo package: library(zoo) z - read.zoo(Date1.txt, header = TRUE, sep = ,, format = %m/%d/%Y) or using chron: library(zoo) library(chron) z -

Re: [R] Date conversions

2009-07-11 Thread Gabor Grothendieck
Try: format(d, %a) or format(d, %A) or as.POSIXlt(d)$wday There is also day.of.week in chron. On Sat, Jul 11, 2009 at 3:42 PM, Mark Knecht markkne...@gmail.com wrote: On Sat, Jul 11, 2009 at 12:05 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: You want %Y, not %y. You might also

Re: [R] Date conversions

2009-07-11 Thread Mark Knecht
Thanks. Will do. Cheers, Mark On Sat, Jul 11, 2009 at 12:49 PM, Gabor Grothendieckggrothendi...@gmail.com wrote: Try: format(d, %a) or format(d, %A) or as.POSIXlt(d)$wday There is also day.of.week in chron. On Sat, Jul 11, 2009 at 3:42 PM, Mark Knecht markkne...@gmail.com wrote: On Sat,

[R] Date code conversion

2009-07-04 Thread Mark Knecht
Hi, Is there a function that will convert this sort of date code which looks like years from 1900 + month_number + day_number with no spaces? As an example Jan. 3rd 2008 would be written as 1080103. Thanks, Mark __ R-help@r-project.org mailing list

Re: [R] Date code conversion

2009-07-04 Thread Allan Engelhardt
Try help(strptime). Example strptime(1080103L + 19e6L, %Y%m%d) # [1] 2008-01-03 (This assumes your input is an integer but you can just drop the L if you want) On 04/07/09 19:37, Mark Knecht wrote: Hi, Is there a function that will convert this sort of date code which looks like years

Re: [R] Date code conversion

2009-07-04 Thread Mark Knecht
On Sat, Jul 4, 2009 at 12:10 PM, Allan Engelhardtall...@cybaea.com wrote: Try help(strptime).  Example strptime(1080103L + 19e6L, %Y%m%d) # [1] 2008-01-03 (This assumes your input is an integer but you can just drop the L if you want) On 04/07/09 19:37, Mark Knecht wrote: Hi, Is

Re: [R] Date code conversion

2009-07-04 Thread Mark Knecht
On Sat, Jul 4, 2009 at 12:24 PM, Mark Knechtmarkkne...@gmail.com wrote: On Sat, Jul 4, 2009 at 12:10 PM, Allan Engelhardtall...@cybaea.com wrote: Try help(strptime).  Example strptime(1080103L + 19e6L, %Y%m%d) # [1] 2008-01-03 (This assumes your input is an integer but you can just drop the

[R] Date frame

2009-03-11 Thread Tammy Ma
Hi, All, How to make a data frame, each row of data frame store the different length of vector? Thanks. Tammy _ Show them the way! Add maps and directions to your party invites.

Re: [R] Date frame

2009-03-11 Thread jim holtman
It is called a list. On Wed, Mar 11, 2009 at 6:32 AM, Tammy Ma metal_lical...@live.com wrote: Hi, All, How to make a data frame, each row of data frame store the different length of vector? Thanks. Tammy _ Show them the

Re: [R] Date frame

2009-03-11 Thread Tammy Ma
. Tammy Date: Wed, 11 Mar 2009 07:50:37 -0400 Subject: Re: [R] Date frame From: jholt...@gmail.com To: metal_lical...@live.com CC: r-help@r-project.org It is called a list. On Wed, Mar 11, 2009 at 6:32 AM, Tammy Ma metal_lical...@live.com wrote: Hi, All, How to make a data frame

Re: [R] Date frame

2009-03-11 Thread jim holtman
to create a data frame with each row contains different sequence and then put to 3rd column, which seems couldn't be done. thanks. Tammy Date: Wed, 11 Mar 2009 07:50:37 -0400 Subject: Re: [R] Date frame From: jholt...@gmail.com To: metal_lical...@live.com CC: r-help@r-project.org

[R] Date conversion

2009-03-05 Thread Pele
Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007 02DEC2007 Thanks in

Re: [R] Date conversion

2009-03-05 Thread Uwe Ligges
Pele wrote: Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for first record, etc..)? My data set has 1 million records. DATE 11DEC2006 11SEP2006 01APR2007

Re: [R] Date conversion

2009-03-05 Thread Sundar Dorai-Raj
Hi, There are possibly several ways to do this. My approach would be: dates - strptime(as.character(DATE), %d%b%Y) year - dates$year + 1900 week - floor(dates$yday/365 * 52) HTH, --sundar On Thu, Mar 5, 2009 at 8:58 AM, Pele drdi...@yahoo.com wrote: Hi R users, I have a factor variable

Re: [R] Date conversion

2009-03-05 Thread Pele
Hi Uwe, You are correct - that was a type O (52) and thanks for you your suggestion that works.. Pele wrote: Hi R users, I have a factor variable called date as shown below: Can anyone share the best / most efficient way to extract year and week (e.g. year = 2006, week = 52 for

[R] Date functions

2009-01-30 Thread ehxpieterse
Hi there, I am completely new to R and would like to do two things with date functions: 1. Compute any date from a specified starting point, e.g. x - 2 months 2. How do I determine the weekday of any given date? Thanks in advance -- View this message in context:

Re: [R] Date functions

2009-01-30 Thread Gabor Grothendieck
# 1 d - Sys.Date() seq(d, len = 2, by = 2 months)[2] # 2 as.numeric(format(d, %w)) # 0 = Sunday # or format(d, %a) See R News 4/1 for more info and the table at the end of it in particular. On Fri, Jan 30, 2009 at 9:54 AM, ehxpieterse eduard.piete...@macquarie.com wrote: Hi there, I am

Re: [R] date operations

2008-12-03 Thread Christophe Dutang
Thanks a lot Envoyé de mon iPhone Le 3 déc. 08 à 00:39, jim holtman [EMAIL PROTECTED] a écrit : If you want to do the addition, 'unclass' the variable: alpha2+4 [1] 2008-12-25 alpha2 + unclass(alpha1) [1] 2009-02-15 On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL

Re: [R] date operations

2008-12-03 Thread Gabor Grothendieck
What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods

Re: [R] date operations

2008-12-03 Thread Gavin Simpson
On Wed, 2008-12-03 at 13:18 -0500, Gabor Grothendieck wrote: What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 It also works if you flip the ordering: alpha2 + alpha1 [1] 2009-02-15 Warning message: Incompatible methods (+.Date,

Re: [R] date operations

2008-12-03 Thread Gabor Grothendieck
On Wed, Dec 3, 2008 at 1:57 PM, Gavin Simpson [EMAIL PROTECTED] wrote: On Wed, 2008-12-03 at 13:18 -0500, Gabor Grothendieck wrote: What is odd is that it seems to run ok if we call +.Date directly: +.Date(alpha1, alpha2) [1] 2009-02-15 It also works if you flip the ordering: alpha2 +

Re: [R] date operations

2008-12-03 Thread Gavin Simpson
On Wed, 2008-12-03 at 14:13 -0500, Gabor Grothendieck wrote: snip / Why it works is not odd if you look at the help for ?`+.Date`, which shows that for this method (correct term?) we need 'date' + 'x', where 'date' is an object of class Date and 'x' is numeric. In fact what it says is

[R] date operations

2008-12-02 Thread Christophe Dutang
Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have

<    1   2   3   4   5   >