Re: [R] date conversion problem

2020-08-13 Thread Abdoulaye Sarr
Hi Jim,

Thanks for the hint, that makes sense and I'll arrange accordingly.
Best regards,
Abdoulaye

On Thu, Aug 13, 2020 at 8:38 AM Jim Lemon  wrote:

> Hi Abdoulaye,
> It looks to me as though your offsets are in hours, not days. You can
> get a rough date like this:
>
> time<-c(1569072,1569096,1569120,1569144,
>  1569168,1569192,1569216,1569240)
> time_d<-as.Date("1800-01-01")+time/24
> time_d
> [1] "1979-01-01" "1979-01-02" "1979-01-03" "1979-01-04" "1979-01-05"
> [6] "1979-01-06" "1979-01-07" "1979-01-08"
>
> Jim
>
> On Thu, Aug 13, 2020 at 6:10 PM Abdoulaye Sarr 
> wrote:
> >
> > I have dataset with time sine 1800-01-01 and extracted data from 1981 to
> > 2019 and used these lines for the data conversion:
> > > time_d <- as.Date(time, format="%j", origin=as.Date("1800-01-01"))
> > > time_years <- format(time_d, "%Y")
> > > time_months <- format(time_d, "%m")
> > > time_year_months <- format(time_d, "%Y-%m")
> > > head(time_d)
> > [1] "6095-12-22" "6096-01-15" "6096-02-08" "6096-03-03" "6096-03-27"
> > "6096-04-20"
> >
> > As you see these gregorian dates are unrealistic and wonder what I am
> doing
> > wrong?
> > The time from the raw file in Jd are like this:
> >
> > > time
> >[1] 1569072 1569096 1569120 1569144 1569168 1569192 1569216
> 1569240etc.
> >
> > Hope hint and/or suggestion to solve this.
> >
> > Best regards
> >
> > [[alternative HTML version deleted]]
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion problem

2020-08-13 Thread Jim Lemon
Hi Abdoulaye,
It looks to me as though your offsets are in hours, not days. You can
get a rough date like this:

time<-c(1569072,1569096,1569120,1569144,
 1569168,1569192,1569216,1569240)
time_d<-as.Date("1800-01-01")+time/24
time_d
[1] "1979-01-01" "1979-01-02" "1979-01-03" "1979-01-04" "1979-01-05"
[6] "1979-01-06" "1979-01-07" "1979-01-08"

Jim

On Thu, Aug 13, 2020 at 6:10 PM Abdoulaye Sarr  wrote:
>
> I have dataset with time sine 1800-01-01 and extracted data from 1981 to
> 2019 and used these lines for the data conversion:
> > time_d <- as.Date(time, format="%j", origin=as.Date("1800-01-01"))
> > time_years <- format(time_d, "%Y")
> > time_months <- format(time_d, "%m")
> > time_year_months <- format(time_d, "%Y-%m")
> > head(time_d)
> [1] "6095-12-22" "6096-01-15" "6096-02-08" "6096-03-03" "6096-03-27"
> "6096-04-20"
>
> As you see these gregorian dates are unrealistic and wonder what I am doing
> wrong?
> The time from the raw file in Jd are like this:
>
> > time
>[1] 1569072 1569096 1569120 1569144 1569168 1569192 1569216 1569240etc.
>
> Hope hint and/or suggestion to solve this.
>
> Best regards
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] date conversion problem

2020-08-13 Thread Abdoulaye Sarr
I have dataset with time sine 1800-01-01 and extracted data from 1981 to
2019 and used these lines for the data conversion:
> time_d <- as.Date(time, format="%j", origin=as.Date("1800-01-01"))
> time_years <- format(time_d, "%Y")
> time_months <- format(time_d, "%m")
> time_year_months <- format(time_d, "%Y-%m")
> head(time_d)
[1] "6095-12-22" "6096-01-15" "6096-02-08" "6096-03-03" "6096-03-27"
"6096-04-20"

As you see these gregorian dates are unrealistic and wonder what I am doing
wrong?
The time from the raw file in Jd are like this:

> time
   [1] 1569072 1569096 1569120 1569144 1569168 1569192 1569216 1569240etc.

Hope hint and/or suggestion to solve this.

Best regards

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date Conversion Problem

2020-08-12 Thread Eric Berger
nice

On Wed, Aug 12, 2020 at 6:18 PM Bert Gunter  wrote:

> Extra packages are not needed.
>
> My question is: why change the character representation at all?  See the
> format argument of ?as.Date.
>
> > as.Date("20010102",format="%Y%m%d")
> [1] "2001-01-02" ## the default format for the print method for Date
> objects
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Wed, Aug 12, 2020 at 8:07 AM Eric Berger  wrote:
>
>> library(lubridate)
>> a <- "20200403"
>> lubridate::ymd(a)
>> # 2020-04-03
>>
>> HTH,
>> Eric
>>
>>
>> On Wed, Aug 12, 2020 at 5:57 PM Stephen P. Molnar > >
>> wrote:
>>
>> > i have written an R script which allow me to plot the number of Covid-10
>> > cases reported by he state of Ohio. In that se t of data the date format
>> > is in the form -mm-dd.
>> >
>> > My script uses:
>> >
>> > datebreaks <- seq(as.Date("2020-01-01"), as.Date("2020-08-10"), by="1
>> > week")
>> > .
>> > .
>> > .
>> >+ scale_x_date(breaks=datebreaks)
>> >+ theme(axis.text.x = element_text(angle=30, hjust=1))
>> >
>> > to plot the data.
>> >
>> > The COVID Tracking Project publishes considerably more data than does
>> > the state of Ohio. However, The project supplies daily statistics using
>> > the date format MMDD.I have done some searching, but I can't seem to
>> > find a solution (that I can understand).
>> >
>> > How can I change the date forma from MMDD tp -MM-DD?
>> >
>> > Thanks is advanced.
>> >
>> > --
>> > Stephen P. Molnar, Ph.D.
>> > www.molecular-modeling.net
>> > 614.312.7528 (c)
>> > Skype:  smolnar1
>> >
>> > __
>> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> > https://stat.ethz.ch/mailman/listinfo/r-help
>> > PLEASE do read the posting guide
>> > http://www.R-project.org/posting-guide.html
>> > and provide commented, minimal, self-contained, reproducible code.
>> >
>>
>> [[alternative HTML version deleted]]
>>
>> __
>> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date Conversion Problem

2020-08-12 Thread Bert Gunter
Extra packages are not needed.

My question is: why change the character representation at all?  See the
format argument of ?as.Date.

> as.Date("20010102",format="%Y%m%d")
[1] "2001-01-02" ## the default format for the print method for Date objects


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Wed, Aug 12, 2020 at 8:07 AM Eric Berger  wrote:

> library(lubridate)
> a <- "20200403"
> lubridate::ymd(a)
> # 2020-04-03
>
> HTH,
> Eric
>
>
> On Wed, Aug 12, 2020 at 5:57 PM Stephen P. Molnar 
> wrote:
>
> > i have written an R script which allow me to plot the number of Covid-10
> > cases reported by he state of Ohio. In that se t of data the date format
> > is in the form -mm-dd.
> >
> > My script uses:
> >
> > datebreaks <- seq(as.Date("2020-01-01"), as.Date("2020-08-10"), by="1
> > week")
> > .
> > .
> > .
> >+ scale_x_date(breaks=datebreaks)
> >+ theme(axis.text.x = element_text(angle=30, hjust=1))
> >
> > to plot the data.
> >
> > The COVID Tracking Project publishes considerably more data than does
> > the state of Ohio. However, The project supplies daily statistics using
> > the date format MMDD.I have done some searching, but I can't seem to
> > find a solution (that I can understand).
> >
> > How can I change the date forma from MMDD tp -MM-DD?
> >
> > Thanks is advanced.
> >
> > --
> > Stephen P. Molnar, Ph.D.
> > www.molecular-modeling.net
> > 614.312.7528 (c)
> > Skype:  smolnar1
> >
> > __
> > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
> [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date Conversion Problem

2020-08-12 Thread Eric Berger
library(lubridate)
a <- "20200403"
lubridate::ymd(a)
# 2020-04-03

HTH,
Eric


On Wed, Aug 12, 2020 at 5:57 PM Stephen P. Molnar 
wrote:

> i have written an R script which allow me to plot the number of Covid-10
> cases reported by he state of Ohio. In that se t of data the date format
> is in the form -mm-dd.
>
> My script uses:
>
> datebreaks <- seq(as.Date("2020-01-01"), as.Date("2020-08-10"), by="1
> week")
> .
> .
> .
>+ scale_x_date(breaks=datebreaks)
>+ theme(axis.text.x = element_text(angle=30, hjust=1))
>
> to plot the data.
>
> The COVID Tracking Project publishes considerably more data than does
> the state of Ohio. However, The project supplies daily statistics using
> the date format MMDD.I have done some searching, but I can't seem to
> find a solution (that I can understand).
>
> How can I change the date forma from MMDD tp -MM-DD?
>
> Thanks is advanced.
>
> --
> Stephen P. Molnar, Ph.D.
> www.molecular-modeling.net
> 614.312.7528 (c)
> Skype:  smolnar1
>
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Date Conversion Problem

2020-08-12 Thread Stephen P. Molnar
i have written an R script which allow me to plot the number of Covid-10 
cases reported by he state of Ohio. In that se t of data the date format 
is in the form -mm-dd.


My script uses:

datebreaks <- seq(as.Date("2020-01-01"), as.Date("2020-08-10"), by="1 week")
   .
   .
   .
  + scale_x_date(breaks=datebreaks)
  + theme(axis.text.x = element_text(angle=30, hjust=1))

to plot the data.

The COVID Tracking Project publishes considerably more data than does 
the state of Ohio. However, The project supplies daily statistics using 
the date format MMDD.I have done some searching, but I can't seem to 
find a solution (that I can understand).


How can I change the date forma from MMDD tp -MM-DD?

Thanks is advanced.

--
Stephen P. Molnar, Ph.D.
www.molecular-modeling.net
614.312.7528 (c)
Skype:  smolnar1

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion

2011-03-18 Thread Patrick Connolly
On Wed, 16-Mar-2011 at 07:58PM -0700, Joshua Wiley wrote:

| Hi Erin,
| 
| I am not sure what a seq.Date object is.  My first thought is that
| you are talking about the date method for seq(), but there are
| hundreds of packages I do not know.  In any case, here is what I think
| you want.
| 
| Josh
| 
| ## A small example is always nice
| dat - ts(1:12, frequency = 12,
|   start = c(1998, 1), end = c(2010, 12))
| 
| ## Achim and Gabor's wonderful package
| require(zoo)
| ## now just convert to a date
| as.Date(dat)

I'm impressed with that approach but can't see how it works.

The object dat is of class ts.  How does having the zoo package in
the search path influence how as.Date() works?  I didn't notice in the
help file for as.Data anything that mentioned zoo and ts objects.

TIA

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~}   Great minds discuss ideas
 _( Y )_ Average minds discuss events 
(:_~*~_:)  Small minds discuss people  
 (_)-(_)  . Eleanor Roosevelt
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion

2011-03-18 Thread Joshua Wiley
Hi Patrick,

On Fri, Mar 18, 2011 at 12:17 PM, Patrick Connolly
p_conno...@slingshot.co.nz wrote:
 On Wed, 16-Mar-2011 at 07:58PM -0700, Joshua Wiley wrote:
 | ## A small example is always nice
 | dat - ts(1:12, frequency = 12,
 |   start = c(1998, 1), end = c(2010, 12))
 |
 | ## Achim and Gabor's wonderful package
 | require(zoo)
 | ## now just convert to a date
 | as.Date(dat)

 I'm impressed with that approach but can't see how it works.

 The object dat is of class ts.  How does having the zoo package in
 the search path influence how as.Date() works?  I didn't notice in the
 help file for as.Data anything that mentioned zoo and ts objects.

It is just one of those things you would have to know or find (e.g.,
searching via findFn() from package sos or the like).  zoo defines
an S3 method for as.Date().  To see this:

require(zoo)
methods(as.Date) ## show current methods for as.Date
## now if you want to see exactly *how* it works:
getAnywhere(as.Date.ts) ## getAnywhere is needed because it is in
zoo's namespace

Cheers,

Josh



 TIA

 --
 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
   ___    Patrick Connolly
  {~._.~}                   Great minds discuss ideas
  _( Y )_                 Average minds discuss events
 (:_~*~_:)                  Small minds discuss people
  (_)-(_)                              . Eleanor Roosevelt

 ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] date conversion

2011-03-16 Thread Erin Hodgess
Dear R People:

I have a monthly time series which runs from January 1998 to December 2010.

When I use tsp I get the following:

 tsp(ibm$ts)
[1] 1998.000 2010.917   12.000


Is there an easy way to convert this to a seq.Date object, please?

I would like to have something to the effect of
1998/01/01  2010/12/01

Thanks,
Erin



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion

2011-03-16 Thread Joshua Wiley
Hi Erin,

I am not sure what a seq.Date object is.  My first thought is that
you are talking about the date method for seq(), but there are
hundreds of packages I do not know.  In any case, here is what I think
you want.

Josh

## A small example is always nice
dat - ts(1:12, frequency = 12,
  start = c(1998, 1), end = c(2010, 12))

## Achim and Gabor's wonderful package
require(zoo)
## now just convert to a date
as.Date(dat)

On Wed, Mar 16, 2011 at 7:22 PM, Erin Hodgess erinm.hodg...@gmail.com wrote:
 Dear R People:

 I have a monthly time series which runs from January 1998 to December 2010.

 When I use tsp I get the following:

 tsp(ibm$ts)
 [1] 1998.000 2010.917   12.000


 Is there an easy way to convert this to a seq.Date object, please?

 I would like to have something to the effect of
 1998/01/01  2010/12/01

 Thanks,
 Erin



 --
 Erin Hodgess
 Associate Professor
 Department of Computer and Mathematical Sciences
 University of Houston - Downtown
 mailto: erinm.hodg...@gmail.com

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion

2011-03-16 Thread Gabor Grothendieck
On Wed, Mar 16, 2011 at 10:22 PM, Erin Hodgess erinm.hodg...@gmail.com wrote:
 Dear R People:

 I have a monthly time series which runs from January 1998 to December 2010.

 When I use tsp I get the following:

 tsp(ibm$ts)
 [1] 1998.000 2010.917   12.000


 Is there an easy way to convert this to a seq.Date object, please?

 I would like to have something to the effect of
 1998/01/01  2010/12/01


This would be clearer if you gave a complete example but creating a
sample series, ser, we can create a zoo series using Date class times
like this:

 library(zoo)
 ser - ts(seq(12*13), start = 1998, frequency = 12)
 tsp(ser)
[1] 1998.000 2010.917   12.000
 z - as.zoo(ser)
 time(z) - as.Date(as.yearmon(time(ser)))
 head(z)
1998-01-01 1998-02-01 1998-03-01 1998-04-01 1998-05-01 1998-06-01
 1  2  3  4  5  6

You might actually prefer to leave it as yearmon class in which case its

 z - as.zoo(ser)
 time(z) - as.yearmon(time(z))
 head(z)
Jan 1998 Feb 1998 Mar 1998 Apr 1998 May 1998 Jun 1998
   123456

-- 
Statistics  Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion

2011-03-16 Thread David Winsemius


On Mar 16, 2011, at 10:22 PM, Erin Hodgess wrote:


Dear R People:

I have a monthly time series which runs from January 1998 to  
December 2010.


When I use tsp I get the following:


tsp(ibm$ts)

[1] 1998.000 2010.917   12.000


Is there an easy way to convert this to a seq.Date object, please?

I would like to have something to the effect of
1998/01/01  2010/12/01


Several (at least two, anyway) packages have functions to convert  
fractional years:


RSiteSearch(fractional year dates)

or you can use
library(sos)

Most date formats are in days so another option would be something  
along these lines


conv.frac.yr - function(yr) as.Date( (yr-1970)*(365 + (yr %% 4 ==  
0)), origin=1970-01-01 )


Unfortunately that doesn't take into account leap years in any except  
the current year so:


 as.Date(sapply(c (1998.000, 2010.917), conv.frac.yr),  
origin=1970-01-01)

[1] 1997-12-25 2010-11-21

Not acceptable. Since others have already wrestled with this  use  
their work to your advantage.






Thanks,
Erin



--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] date conversion and plot

2010-11-08 Thread sachinthaka . abeywardana

Hi All,

I have a date in the format of yymmdd (without any of the backslashes, eg.
100731). How do I convert this into a Rdate and plot it? I don't want the
number of days from 1970's showing up as my date (Its the date I require).

Thanks,
Sachin
p.s. sorry about the corporate notice I can't remove it.

--- Please consider the environment before printing this email --- 

Allianz - Best General Insurance Company of the Year 2010*
Allianz - General Insurance Company of the Year 2009+ 

* Australian Banking and Finance Insurance Awards
+ Australia and New Zealand Insurance Industry Awards 

This email and any attachments has been sent by Allianz Australia Insurance 
Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
confidential, may contain personal information and may be subject to legal 
professional privilege. Unauthorised use is strictly prohibited and may be 
unlawful. If you have received this by mistake, confidentiality and any legal 
privilege are not waived or lost and we ask that you contact the sender and 
delete and destroy this and any other copies. In relation to any legal use you 
may make of the contents of this email, you must ensure that you comply with 
the Privacy Act (Cth) 1988 and you should note that the contents may be subject 
to copyright and therefore may not be reproduced, communicated or adapted 
without the express consent of the owner of the copyright.
Allianz will not be liable in connection with any data corruption, 
interruption, delay, computer virus or unauthorised access or amendment to the 
contents of this email. If this email is a commercial electronic message and 
you would prefer not to receive further commercial electronic messages from 
Allianz, please forward a copy of this email to unsubscr...@allianz.com.au with 
the word unsubscribe in the subject header.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] date conversion and plot

2010-11-08 Thread Hans-Joachim Müller
Good morning,

try this:
#your date format
datum-c(100907,101008,101109)
#convert it (works with and without as.Date)
datum-as.Date(strptime(datum,(%y%m%d)))
plot(datum,5:7)

I hope it works for you

Hajo

Am 09.11.2010 06:37, schrieb sachinthaka.abeyward...@allianz.com.au:
 Hi All,

 I have a date in the format of yymmdd (without any of the backslashes, eg.
 100731). How do I convert this into a Rdate and plot it? I don't want the
 number of days from 1970's showing up as my date (Its the date I require).

 Thanks,
 Sachin
 p.s. sorry about the corporate notice I can't remove it.

 --- Please consider the environment before printing this email --- 

 Allianz - Best General Insurance Company of the Year 2010*
 Allianz - General Insurance Company of the Year 2009+ 

 * Australian Banking and Finance Insurance Awards
 + Australia and New Zealand Insurance Industry Awards 

 This email and any attachments has been sent by Allianz Australia Insurance 
 Limited (ABN 15 000 122 850) and is intended solely for the addressee. It is 
 confidential, may contain personal information and may be subject to legal 
 professional privilege. Unauthorised use is strictly prohibited and may be 
 unlawful. If you have received this by mistake, confidentiality and any legal 
 privilege are not waived or lost and we ask that you contact the sender and 
 delete and destroy this and any other copies. In relation to any legal use 
 you may make of the contents of this email, you must ensure that you comply 
 with the Privacy Act (Cth) 1988 and you should note that the contents may be 
 subject to copyright and therefore may not be reproduced, communicated or 
 adapted without the express consent of the owner of the copyright.
 Allianz will not be liable in connection with any data corruption, 
 interruption, delay, computer virus or unauthorised access or amendment to 
 the contents of this email. If this email is a commercial electronic message 
 and you would prefer not to receive further commercial electronic messages 
 from Allianz, please forward a copy of this email to 
 unsubscr...@allianz.com.au with the word unsubscribe in the subject header.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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
 as.date(as.character(dat$BEGINDATUM[4]))
[1] 11Jan2007

How can i convert these factors to make calculations possible.

Thanks for the answer,
Andre

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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
  as.date(as.character(dat$BEGINDATUM[4]))
 [1] 11Jan2007

 How can i convert these factors to make calculations possible.

 Thanks for the answer,
 Andre

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 thanks in advance.


# Define arbitrary initial date value
ini - as.Date(2010/1/1, %Y/%m/%d)
# Generate arbitrary data frame consisting of date values
dat - data.frame(y1 = seq(ini, ini + 5, 1), y2 = seq(ini + 365, ini + 365 +
5, 1), y3 = seq(ini + 365*2, ini + 365*2 + 5, 1))
# Convert date values to next Friday
y - sapply(dat, function(x) ifelse(weekdays(x, abbreviate = TRUE) %in%
Mon, x + 4,
 ifelse(weekdays(x, abbreviate =
TRUE) %in% Tue, x + 3,
  ifelse(weekdays(x, abbreviate =
TRUE) %in% Wed, x + 2,
   ifelse(weekdays(x, abbreviate =
TRUE) %in% Thu, x + 1,
ifelse(weekdays(x, abbreviate =
TRUE) %in% Sat, x + 6,
 ifelse(weekdays(x, abbreviate =
TRUE) %in% Mon, x + 7, x)))

# Convert interger into date class
class(y) - Date



-- 
Steven

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 would be greatly apprecited if you could provide any solution to this
 problem.


The zoo-quickref vignette in the zoo package defines a one line
nextfri function which does this.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date conversion

2010-06-11 Thread Felipe Carrillo
Thanks Joshua, I wanted to use some kind of date format in latex
but ended up using exactly what you and Marc suggested.
 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA



- Original Message 
 From: Joshua Wiley 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 
 AM, Felipe Carrillo
 href=mailto:mazatlanmex...@yahoo.com;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 10, 
 2010. I am using:

 \documentclass[11pt]{article}
 
 \usepackage{longtable,verbatim}
 \usepackage{ctable}
 
 \usepackage{datetime}
 \title{my title}
 \begin{document}
 
   % Convert date
 \dddate\3/10/10
 
 end{document}

 My report is changing every two weeks so I will 
 eventually
 use \Sexpr{report[1,1]} to grab the date from column 1, row 
 1
 of a table named report but right now my report has the date
 
 formated as described above (3/10/10).


 Felipe D. 
 Carrillo
 Supervisory Fishery Biologist
 Department of the 
 Interior
 US Fish  Wildlife Service
 California, 
 USA




 
 __
  ymailto=mailto:R-help@r-project.org; 
 href=mailto:R-help@r-project.org;R-help@r-project.org mailing list
 
  https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the 
 posting guide http://www.R-project.org/posting-guide.html
 and provide 
 commented, minimal, self-contained, reproducible code.




-- 
 
Joshua Wiley
Senior in Psychology
University of California, 
 Riverside
http://www.joshuawiley.com/




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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
\dddate\3/10/10
end{document} 

My report is changing every two weeks so I will eventually 
use \Sexpr{report[1,1]} to grab the date from column 1, row 1
of a table named report but right now my report has the date
formated as described above (3/10/10).

 
Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 10, 2010. I am using:

 \documentclass[11pt]{article}
 \usepackage{longtable,verbatim}
 \usepackage{ctable}
 \usepackage{datetime}
 \title{my title}
 \begin{document}
   % Convert date
 \dddate\3/10/10
 end{document}

 My report is changing every two weeks so I will eventually
 use \Sexpr{report[1,1]} to grab the date from column 1, row 1
 of a table named report but right now my report has the date
 formated as described above (3/10/10).


 Felipe D. Carrillo
 Supervisory Fishery Biologist
 Department of the Interior
 US Fish  Wildlife Service
 California, USA




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Joshua Wiley
Senior in Psychology
University of California, Riverside
http://www.joshuawiley.com/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 22:48:55.558
9  800 03/02/09 22:51:21.112
10 900 03/02/09 22:58:41.860

zdates-as.POSIXct(strptime(paste(z[,2],z[,3]), %d/%m/%Y
%H:%M:%OS),origin=1970-01-01 );

 head(zdates)
[1] 0009-02-03 22:20:51 GMT 0009-02-03 22:28:19 GMT 0009-02-03 22:33:34
GMT
[4] 0009-02-03 22:40:22 GMT 0009-02-03 22:41:38 GMT 0009-02-03 22:42:51
GMT


Can anyone tell me why I see YEAR as 0009 instead of 2009?


-- 
View this message in context: 
http://n4.nabble.com/Date-conversion-issue-tp1596548p1596548.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 do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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  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 22:48:55.558
 9  800 03/02/09 22:51:21.112
 10 900 03/02/09 22:58:41.860

zdates-as.POSIXct(strptime(paste(z[,2],z[,3]), %d/%m/%Y
 %H:%M:%OS),origin=1970-01-01 );

 head(zdates)
 [1] 0009-02-03 22:20:51 GMT 0009-02-03 22:28:19 GMT 0009-02-03 22:33:34
 GMT
 [4] 0009-02-03 22:40:22 GMT 0009-02-03 22:41:38 GMT 0009-02-03 22:42:51
 GMT


 Can anyone tell me why I see YEAR as 0009 instead of 2009?


 --
 View this message in context: 
 http://n4.nabble.com/Date-conversion-issue-tp1596548p1596548.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 do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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
CAO0004563   NANA  2005-09-01 NA
CAO0073505   NANA  1998-03-05 NA
CAO0079987   NANA  2002-04-14 NA
CAO0182089   NANA  2007-06-10 11/06/07
CAO0194809 17/02/2005 I64  2004-09-04 14/02/05
CAO0204000   NANA  1999-05-31 NA
CAO027   NANA  1999-07-29 NA
CAO0330844 29/11/2001 I64NA NA
CAO0395045   NANA  2007-02-13 14/02/07
CAO0507333   NANA  2005-10-08 NA


I have converted date_admission1 from a character to a date.  I used the
same script to convert DtDeath but it returns the dates in this format:

 NA   NA   NA   NA   0017-02-20
 [6] NA   NA   0029-11-20 NA   NA  
[11] NA   NA   0013-10-20 NA   NA  
[16] NA   0007-12-20 NA   NA   NA  
[21] NA   NA   NA   NA   NA  
[26] NA   NA   NA   NA   NA  
[31] NA   NA   NA   NA   NA  
[36] NA   NA   NA   NA   NA  
[41] NA   NA   NA   NA   NA  
[46] NA   0029-01-20 0018-05-20 NA   NA  
[51] NA   NA   NA   NA   NA  
[56] NA   0013-07-20 NA   NA   NA  
[61] NA   0026-07-20 NA   NA   NA  
[66] 0029-04-20 NA   NA   NA   0012-12-20
[71] NA   NA   NA   NA   NA  
[76] NA   NA   NA   NA   NA  
[81] NA   NA   0022-01-20 NA   0029-05-20
[86] NA   NA   NA   NA   0022-02-20
[91] NA  

I've tried as.Date(as.character(DtDeath, %d/%m/%y) just in case and have
used different versions of the format (%m/%d/%Y, and the reverse)but still
get the incorrect format.  I'm not sure what the problem is?

Thanks,
natalie
-- 
View this message in context: 
http://n4.nabble.com/Date-conversion-problem-tp1578296p1578296.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 do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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


-Don

At 8:09 AM -0800 3/4/10, Newbie19_02 wrote:

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
CAO0004563   NANA  2005-09-01 NA
CAO0073505   NANA  1998-03-05 NA
CAO0079987   NANA  2002-04-14 NA
CAO0182089   NANA  2007-06-10 11/06/07
CAO0194809 17/02/2005 I64  2004-09-04 14/02/05
CAO0204000   NANA  1999-05-31 NA
CAO027   NANA  1999-07-29 NA
CAO0330844 29/11/2001 I64NA NA
CAO0395045   NANA  2007-02-13 14/02/07
CAO0507333   NANA  2005-10-08 NA


I have converted date_admission1 from a character to a date.  I used the
same script to convert DtDeath but it returns the dates in this format:

 NA   NA   NA   NA   0017-02-20
 [6] NA   NA   0029-11-20 NA   NA 
[11] NA   NA   0013-10-20 NA   NA 
[16] NA   0007-12-20 NA   NA   NA 
[21] NA   NA   NA   NA   NA 
[26] NA   NA   NA   NA   NA 
[31] NA   NA   NA   NA   NA 
[36] NA   NA   NA   NA   NA 
[41] NA   NA   NA   NA   NA 
[46] NA   0029-01-20 0018-05-20 NA   NA 
[51] NA   NA   NA   NA   NA 
[56] NA   0013-07-20 NA   NA   NA 
[61] NA   0026-07-20 NA   NA   NA 
[66] 0029-04-20 NA   NA   NA   0012-12-20
[71] NA   NA   NA   NA   NA 
[76] NA   NA   NA   NA   NA 
[81] NA   NA   0022-01-20 NA   0029-05-20

[86] NA   NA   NA   NA   0022-02-20
[91] NA 


I've tried as.Date(as.character(DtDeath, %d/%m/%y) just in case and have
used different versions of the format (%m/%d/%Y, and the reverse)but still
get the incorrect format.  I'm not sure what the problem is?

Thanks,
natalie
--
View this message in context: 
http://*n4.nabble.com/Date-conversion-problem-tp1578296p1578296.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 do read the posting guide http://*www.*R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 )
[1] 2009-09-30

I don't understand why this is happening. I realise that i can get
around this by doing as.Date(as.character(x)), but would be nice to
understand why it doesn't work directly.

C xx

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 problem last week. I am not sure how Bill Gates does his 
times but for R see Rnews 4(1).

There are slight differences between POSIX and Date classes

NB If you run EST in DST periods Bill Gates still gives the file stamp as 
DST in Vista and XP.
I would presume that it is the same for other zones where there is summer 
time zones


Regards

Duncan Mackay
Department of Agronomy and Soil Science
University of New England
ARMIDALE NSW 2351
Email: home: ma...@northnet.com.au




At 00:51 22/10/2009, you wrote:

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 )
[1] 2009-09-30

I don't understand why this is happening. I realise that i can get
around this by doing as.Date(as.character(x)), but would be nice to
understand why it doesn't work directly.

C xx

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[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 advance for any help!
-- 
View this message in context: 
http://www.nabble.com/Date-conversion-tp22355788p22355788.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 do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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



Since I am not in the correct locale:

Sys.setlocale(locale=C)
date - strptime(DATE, %d%B%Y)
format(date, %Y)
format(date, %W) # which is certainly not 52

Uwe Ligges






Thanks in advance for any help!


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 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 advance for any help!
 --
 View this message in context: 
 http://www.nabble.com/Date-conversion-tp22355788p22355788.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 do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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 first record, etc..)?  My data set has 1 million records.
 
 DATE
 11DEC2006 
 11SEP2006
 01APR2007
 02DEC2007
 
 
 Thanks in advance for any help!
 

-- 
View this message in context: 
http://www.nabble.com/Date-conversion-tp22355788p22356526.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 do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Date conversion

2008-11-13 Thread Dr. Alireza Zolfaghari
Hi List,
If I have a date format as:
d - 2001/1/1
I can easily convert it to number by using as.Date(d).

But if I have d-1/1/2001, it does not work. Does anyone know how I can
convert it using pre-written function in R?

Regards,
Alireza

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Date conversion

2008-11-13 Thread Peter Dalgaard
Dr. Alireza Zolfaghari wrote:
 Hi List,
 If I have a date format as:
 d - 2001/1/1
 I can easily convert it to number by using as.Date(d).

Yes. If it means January the 1st and not 1st of January, that is...


 But if I have d-1/1/2001, it does not work. Does anyone know how I can
 convert it using pre-written function in R?

as.Date has a format= argument. See the Examples section in help(as.Date).

 Regards,
 Alireza


-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.