2015-04-17 107 views
1

我已經下載了json格式的鳴叫。現在我想表示鳴叫時間的創建速度。有一個名爲'created at'的變量,表示鳴叫的創建時間。我有這個變量格式爲:在R讀取鳴叫時間

Thu Apr 09 15:43:18 +0000 2015 

我能夠讀取所有其他的事情,但不知道如何閱讀本+ 0000.Previously我試圖R中讀這篇文章,這是成功的:

Thu Apr 09 15:43:18 2015 

對於閱讀這個上面的變量,我用下面的代碼:

earlier <-strptime("Thu Apr 09 15:43:18 2015","%a %b %d %H:%M:%S %Y") 

請幫助我,我怎麼能在R.閱讀第一碼

+0

@akrun它給出了這樣的錯誤:」字符串不是以標準的明確格式「 –

+0

我沒有得到R 3.1.3的錯誤 – akrun

回答

1

您可以嘗試

as.POSIXct('Thu Apr 09 15:43:18 +0000 2015', 
         format='%a %b %d %H:%M:%S %z %Y', tz='GMT') 
#[1] "2015-04-09 15:43:18 GMT" 

根據?strptime

‘%z’ Signed offset in hours and minutes from UTC, so ‘-0800’ is 8 hours behind UTC. Values up to ‘+1400’ are accepted as from R 3.1.1: previous versions only accepted up to ‘+1200’. (Standard only for output.)