使用 rtweet 的 ts_plot() 绘制推文时时区不起作用

time zone not working when plotting tweets with rtweet's ts_plot()

在 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)

谢谢

我看到了同样的问题。我会提前使用 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 package (v0.3.0)

于 2020-04-28 创建