Kanwar_Singh
Kanwar_Singh

Reputation: 133

Reading tweet time in R

I have downloaded tweets in json format.Now i want to represent the tweets creation rate with respect to time.There is a variable named 'created at' which represents when the tweet was created.I have this variable in this format:

Thu Apr 09 15:43:18 +0000 2015

I was able to read all the other things,but no idea how to read this +0000.Previously i tried reading this in R,which was a success:

Thu Apr 09 15:43:18 2015

For reading this above variable i used this following code:

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

Please help me how i can read the first code in R.

Upvotes: 1

Views: 115

Answers (1)

akrun
akrun

Reputation: 887118

You can try

 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"

According to ?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.)

Upvotes: 1

Related Questions