1

rtweet 的 GitHub 上有一个已关闭的问题,说您可以在 ts_plot https://github.com/ropensci/rtweet/issues/227中使用 tz

rt <- search_tweets("rstats", n = 500)

## with default timezone (UTC)
ts_plot(rt, "hours")

## with american central time zone
ts_plot(rt, "hours", tz = "US/Central") 

但我在我的代码中尝试这个,我总是得到 UTM 小时

ts_plot(tweets, "mins", tz = "America/Montevideo") +
  labs(x = NULL, y = NULL,
       title = "Frequency of tweets",
       subtitle = paste0(format(min(tweets$created_at), "%d/%m/%Y - %H:%M:%S", tz = "America/Montevideo"), " to ", format(max(tweets$created_at),"%d/%m/%Y - %H:%M:%S", tz = "America/Montevideo")),
       caption = "Data collected from Twitter's REST API via rtweet") 

tz 对于字幕工作正常,但对于实际的 t_plot 没有,任何想法是否应该工作?

我直接从 GitHub 下载了包

## install dev version of rtweet from github
remotes::install_github("ropensci/rtweet")
library(rtweet)

谢谢

4

1 回答 1

1

我看到同样的问题。我会提前将时间格式化为您想要的时区mutate()lubridate包。

library(rtweet)
library(dplyr)
library(lubridate)

rt <- search_tweets("rstats", n = 500) %>% 
  mutate(created_at = ymd_hms(format(created_at, tz = "America/Montevideo"))) 

rt %>% 
  ts_plot("mins", tz = "America/Montevideo") +
  labs(x = NULL, y = NULL,
       title = "Frequency of tweets",
       subtitle = paste0(min(rt$created_at), " to ", max(rt$created_at)),
       caption = "Data collected from Twitter's REST API via rtweet") 

reprex 包(v0.3.0)于 2020 年 4 月 28 日创建

于 2020-04-28T15:56:02.393 回答