[R] how to return "date" part of POSIXct

David Winsemius dwinsemius at comcast.net
Thu Mar 18 16:44:09 CET 2010


On Mar 18, 2010, at 11:37 AM, jim holtman wrote:

> Does one of these work for you:
>
>> x <- as.POSIXct('2010-03-18 12:15')
>> x
> [1] "2010-03-18 12:15:00 EDT"
>> unclass(x)
> [1] 1268928900
> attr(,"tzone")
> [1] ""
>> as.vector(x)
> [1] 1268928900

I was guessing he wanted:

 > x <- as.POSIXct('2010-03-18 12:15')
 > as.Date(x)
[1] "2010-03-18"

Or perhaps:
 > unclass(as.Date(x))
[1] 14686

Hard to know since he persists in not following the Posting Guide's  
request to provide examples and specifics for the desired result.

-- 
David.

>>
>
>
> On Thu, Mar 18, 2010 at 11:18 AM, ManInMoon  
> <xmoon2000 at googlemail.com>wrote:
>
>>
>> How do I get a number representing a date from a POSIXct i.e.  
>> removing the
>> time elements?
>> --
>> View this message in context:
>> http://n4.nabble.com/how-to-return-date-part-of-POSIXct-tp1598109p1598109.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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<http://www.r-project.org/posting-guide.html 
>> >
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that you are trying to solve?
>
> 	[[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