我正在使用R代码提取某些YouTube频道的统计信息。
我正在使用tuber
软件包,尤其是get_all_video_stats
函数。
我的问题是,我只希望最近6个月以及自创建频道以来发布的统计信息。
有可能吗?
答案 0 :(得分:0)
使用lubridate
库仅过滤最近6个月的视频统计数据。
library(tuber)
library(dplyr)
library(lubridate)
## Enter your actual credetionals (stub)
## Not run:
yt_oauth("<Enter your app_id>",
"<Enter your app_secret>")
## End(Not run)
vs <- get_all_channel_video_stats("UCbZRdTukTCjFan4onn04sDA")
# "Since creation" data are in vs dataframe
cat("Published since creation: ", nrow(vs))
# last six month data are in vs6 dataframe
vs6 <- vs %>% mutate(publication_date = as_date(publication_date)) %>%
filter(publication_date >= today() - ceiling(365.25 / 2))
cat("Published in last six month:", nrow(vs6))