date

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

date

Veerappa Chetty
Hi,
I have dates as follows:
 1/4/2006 0:00:00 AM
It is a factor  at present.
How do I find out the day of the week from this? How do I convert to Julian
date format?
Thanks.
Chetty

--
Professor of Family Medicine
Boston University
Tel: 617-414-6221, Fax:617-414-3345
emails: [hidden email],[hidden email]

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: date

Michael Weylandt
Three steps:

1) as.character to get character representation
2) as.POSIXct to convert to time
3) julian() or strptime() to get Julian date.

Read the docs (esp on part 2 and 3) to get the format strings just right.

Cheers,
Michael

On Aug 24, 2012, at 10:30 PM, Veerappa Chetty <[hidden email]> wrote:

> Hi,
> I have dates as follows:
> 1/4/2006 0:00:00 AM
> It is a factor  at present.
> How do I find out the day of the week from this? How do I convert to Julian
> date format?
> Thanks.
> Chetty
>
> --
> Professor of Family Medicine
> Boston University
> Tel: 617-414-6221, Fax:617-414-3345
> emails: [hidden email],[hidden email]
>
>    [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: date

arun kirshna
In reply to this post by Veerappa Chetty
HI,
Try this:

dat1<-"01/04/2006 1:10:60 PM"
 dat1<-as.character(dat1)
 strptime(dat1,"%m/%d/%Y %I:%M:%S %p")$yday+1
#[1] 4
A.K.


----- Original Message -----
From: Veerappa Chetty <[hidden email]>
To: [hidden email]
Cc:
Sent: Friday, August 24, 2012 11:30 PM
Subject: [R] date

Hi,
I have dates as follows:
1/4/2006 0:00:00 AM
It is a factor  at present.
How do I find out the day of the week from this? How do I convert to Julian
date format?
Thanks.
Chetty

--
Professor of Family Medicine
Boston University
Tel: 617-414-6221, Fax:617-414-3345
emails: [hidden email],[hidden email]

    [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.


______________________________________________
[hidden email] 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.