我正在R中工作,我需要从格式一栏改为一栏。
9/27/2011 3:33:00 PM
a 价值格式。 在Excel I中,可以使用 Value(
),但我不知道如何在R中这样做。
我的数据表明:
9/27/2011 15:33 a 1 5 9
9/27/2011 15:33 v 2 6 2
9/27/2011 15:34 c 3 7 1
我正在R中工作,我需要从格式一栏改为一栏。
9/27/2011 3:33:00 PM
a 价值格式。 在Excel I中,可以使用 Value(
),但我不知道如何在R中这样做。
我的数据表明:
9/27/2011 15:33 a 1 5 9
9/27/2011 15:33 v 2 6 2
9/27/2011 15:34 c 3 7 1
为了将体格转换为R日期格式,使用as.POSIXct
——那么,你可以使用as.全数<>强制其为数字数值。
> x <- as.POSIXct("9/27/2011 3:33:00 PM", format="%m/%d/%Y %H:%M:%S %p")
> x
[1] "2011-09-27 03:33:00 BST"
> as.numeric(x)
[1] 1317090780
你得到的数值表明,自任意日期(通常为1970年1月1日)以来,第二位数。 请注意,这与Excel不同,因为一个日期是自任意日期以来的天数(1/1/1900,如果我的记忆为我服务的话——我试图不再使用Excel。)
详情见? 日期Classes
这对我有用:
> test=as.POSIXlt("09/13/2006", format="%m/%d/%Y")
> test
[1] "2006-09-13"
> 1900+test$year
[1] 2006
> test$yday
[1] 255
> test$yday/365
[1] 0.6986301
> 1900+test$year+test$yday/366
[1] 2006.697
如果你们需要像在Excel那样的日数,你可以采取类似的做法。
I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was ...
So I implemented a UIDatepicker in one of my applications for scheduling and autodialing teleconferences... everything is pretty much ready to go except, while testing I noticed that when the date ...
I have MMDDYY dates, i.e. today is 111609 How do I convert this to 11/16/2009, in Python?
I am wondering if there is a way to specify the date format in the forms created using CakePHP s $form->inputs(); Please note that this is not the individual $form->input() but instead $form->inputs() ...
Ok, this is really simple, maybe I m a getting a bit burnt out, but seems like it should work, Query XML feed, put out date string, format, display in a cell. The issue is I m a getting a NULL ...
I am exporting a date value from sqlite and placing it into an email. The date appears like this 279498721.322872 I am using Objective C in an Iphone App. Does anyone know how to make this export ...
I m trying to parse timestamp strings like "Sat, 11/01/09 8:00PM EST" in Python, but I m having trouble finding a solution that will handle the abbreviated timezone. I m using dateutil s parse() ...
I love the new DATE datatype in SQL Server 2008, but when I compare a DATE field to a DATETIME field on a linked server (SQL 2005, in this case), like this: DECLARE @MyDate DATE SET @MyDate = CONVERT(...