Convert Twitter Timestamp in R

后端 未结 3 1116

I am new to R and am terrible with handling dates. The following date is returned from a query to the Twitter search API and is stored as a character string in a my dataframe.<

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-09 19:55

    I strongly recommend that you take a look at Jeff Gentry's twitteR package on CRAN. Among other niceties, it parses date strings for you:

    > library(twitteR)
    > tweets = searchTwitter('#rstats')
    > length(tweets)
    [1] 25
    > tweet = tweets[[1]]
    > str(tweet)
    Formal class 'status' [package "twitteR"] with 10 slots
      ..@ text        : chr "The Joy of Sweave \023 A Beginner\031s Guide to Reproducible Research with Sweave: Just& http://goo.gl/fb/APmCb #rstats"
      ..@ favorited   : logi FALSE
      ..@ replyToSN   : chr(0) 
      ..@ created     : POSIXct[1:1], format: "2011-01-18 04:48:05"
      ..@ truncated   : logi FALSE
      ..@ replyToSID  : num(0) 
      ..@ id          : num 2.72e+16
      ..@ replyToUID  : num(0) 
      ..@ statusSource: chr "<a href="http://www.google.com/support/youtube/bin/answer.py?hl=en&answer=164577" rel="nofollow">"| __truncated__
      ..@ screenName  : chr "Rbloggers"
    

提交回复
热议问题