如何添加/追加列表以使用gtrends列表并重新整形到数据框?

时间:2016-06-17 17:20:31

标签: r list dataframe

library(gtrendsR)
user <- "@gmail.com"
psw <- "password"
gconnect(user, psw) 
lang_trend <- gtrends(c("Soccer", "Footbal" , "Basketball"), res="7d")
plot(lang_trend)

enter image description here

我想通过列表上的循环生成类似的resalts:

sport<- as.list(c("Soccer", "Footbal" , "Basketball"))


mylist= list() #create a empty list
for (i in sport) {
  dat <- gtrends(sport[1], res="7d")
  dat$i <- i  # Here I would like to add the name of the sports
  datalist[[i]] <- gtrends(a[1], res="7d") # add it to your list
}

我想生成一个像这样的表/数据框:

Date    Soccer     Football   Basketball
12.06     100        50           30
13.06      90        30           20
14.06      80        40           20

0 个答案:

没有答案