Re: [R] Convert number to Date

2010-03-29 Thread Gabor Grothendieck
There is a discussion of excel dates in R News 4/1. On Mon, Mar 29, 2010 at 11:47 AM, anna wrote: > > Hi Joshua, thank you this worked pretty well. I don't understand all the > details of the dates on excel and R so sorry for not participating more on > my own post. > > - > Anna Lippel > -- >

Re: [R] Convert number to Date

2010-03-29 Thread anna
Hi Joshua, thank you this worked pretty well. I don't understand all the details of the dates on excel and R so sorry for not participating more on my own post. - Anna Lippel -- View this message in context: http://n4.nabble.com/Convert-number-to-Date-tp1691251p1695267.html Sent from the R

Re: [R] Convert number to Date

2010-03-26 Thread Prof Brian Ripley
As an example of the perils, Excel actually has two possible origins, which you can select as an option but whose default differs by OS. And one of them has in fact different origins for dates before and after 1900-02-28. From the help for as.Date in R-devel: % http://support.microsoft.com/kb/

Re: [R] Convert number to Date

2010-03-25 Thread Rolf Turner
On 26/03/2010, at 12:23 PM, Achim Zeileis wrote: > Sorry for coming so late to this thread. One possible explanation for the > R side is the following... > > > On Thu, 25 Mar 2010, Marc Schwartz wrote: > >> On Mar 25, 2010, at 5:41 PM, Joshua Wiley wrote: >> Kind of off the thread a bit

Re: [R] Convert number to Date

2010-03-25 Thread Achim Zeileis
Sorry for coming so late to this thread. One possible explanation for the R side is the following... On Thu, 25 Mar 2010, Marc Schwartz wrote: On Mar 25, 2010, at 5:41 PM, Joshua Wiley wrote: Kind of off the thread a bit, but when I do: as.Date(40182) I ***do not*** get "2080-01-06". I

Re: [R] Convert number to Date

2010-03-25 Thread Marc Schwartz
On Mar 25, 2010, at 5:41 PM, Joshua Wiley wrote: >> Kind of off the thread a bit, but when I do: >> >>> as.Date(40182) >> >> I ***do not*** get "2080-01-06". Instead I get an error: >> >> Error in as.Date.numeric(40182) : 'origin' must be supplied >> >> Am I the only user who gets picked on i

Re: [R] Convert number to Date

2010-03-25 Thread Rolf Turner
On 26/03/2010, at 11:21 AM, Nordlund, Dan (DSHS/RDA) wrote: > Rolf, > > I tried the same thing at first, and got the same error. So I suspect Anna > didn't really use that code either. :-) Thanks! That helps to sooth my paranoia. :-) cheers, Rolf ##

Re: [R] Convert number to Date

2010-03-25 Thread Joshua Wiley
> Kind of off the thread a bit, but when I do: > >> as.Date(40182) > > I ***do not*** get "2080-01-06".  Instead I get an error: > > Error in as.Date.numeric(40182) : 'origin' must be supplied > > Am I the only user who gets picked on in this way, or does it > happen to others as well?  The help on

Re: [R] Convert number to Date

2010-03-25 Thread Nordlund, Dan (DSHS/RDA)
a, WA  98504-5204 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Rolf Turner > Sent: Thursday, March 25, 2010 3:09 PM > To: Joshua Wiley > Cc: r-help@r-project.org > Subject: Re: [R] Convert number to Date

Re: [R] Convert number to Date

2010-03-25 Thread Rolf Turner
Kind of off the thread a bit, but when I do: > as.Date(40182) I ***do not*** get "2080-01-06". Instead I get an error: Error in as.Date.numeric(40182) : 'origin' must be supplied Am I the only user who gets picked on in this way, or does it happen to others as well? The help on as.Date() cl

Re: [R] Convert number to Date

2010-03-25 Thread Nordlund, Dan (DSHS/RDA)
> -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On > Behalf Of Joshua Wiley > Sent: Thursday, March 25, 2010 1:48 PM > To: anna > Cc: r-help@r-project.org > Subject: Re: [R] Convert number to Date > > Dear Anna,

Re: [R] Convert number to Date

2010-03-25 Thread Joshua Wiley
You are quite welcome. After poking around a bit more, I can offer a more detailed explanation on Excel. It does treat 1 January 1900 as the origin. However, while R treats origin as 0, Excel treats it as 1. This explains 1 of the two day change needed for R to get the same results as Excel. T

Re: [R] Convert number to Date

2010-03-25 Thread anna
Hi Josh! yes definitely it makes sense as I got to retrieve a date, but a different one! thanks a lot for the explanation ) - Anna Lippel -- View this message in context: http://n4.nabble.com/Convert-number-to-Date-tp1691251p1691294.html Sent from the R help mailing list archive at Nabble.c

Re: [R] Convert number to Date

2010-03-25 Thread Joshua Wiley
Dear Anna, Rolf's explanation not withstanding, it has to do with differences in how R and Excel treat dates. If you use as.Date(40182, origin="1899-12-30") you will get the same date as Excel. You can look at: http://office.microsoft.com/training/training.aspx?AssetID=RC102786151033&CTT=6&Or

Re: [R] Convert number to Date

2010-03-25 Thread Rolf Turner
On 26/03/2010, at 9:33 AM, anna wrote: > > Hello, I have a date value in excel: 1/4/2010 which in number format gives me > 40182. When I read this with read.xls from R I get same 40182 so what I do > is that I use the as.Date() function but here is what the as.Date() function > returns me: >> as

[R] Convert number to Date

2010-03-25 Thread anna
Hello, I have a date value in excel: 1/4/2010 which in number format gives me 40182. When I read this with read.xls from R I get same 40182 so what I do is that I use the as.Date() function but here is what the as.Date() function returns me: > as.Date(40182) [1] "2080-01-06" Why don't I get the sa