[R] Date object

David Winsemius dwinsemius at comcast.net
Sat Apr 21 19:52:25 CEST 2012


On Apr 21, 2012, at 1:17 PM, Veerappa Chetty wrote:

> HI,
> I have to work with data objects. I have trouble. I would like to  
> convert
> date to a integer of Julian dates omitting hours, minutes etc. I  
> tried as.
> Date and also as.POSIXlt, ct etc.
>
> Please help me to compute the following difference. I get an "NA" for
> output.
>
> 1/14/2006 0:00:00 AM -1/9/2006 0:00:00 AM

I didn't realize this until I started experimenting with your example,  
but there is no 0 hour that is recognized by strptime when using the  
am/pm time format:

 > strptime("1/14/2006 0:01:01 AM", format ="%m/%d/%Y %I:%M:%S %p")
[1] NA
 > strptime("1/14/2006 12:01:01 AM", format ="%m/%d/%Y %I:%M:%S %p")
[1] "2006-01-14 00:01:01"


If you want to offer a reproducible example of your data (not just  
console output we can do more with it.) I suggest you take you vector  
and offer the output of dput() on it.

-- 
David.
>
>
> Thanks.
> Chetty
> -- 
> Professor of Family Medicine
> Boston University
> Tel: 617-414-6221, Fax:617-414-3345
> emails: chettyvk at gmail.com,vchetty at bu.edu
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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



More information about the R-help mailing list