【问题标题】:Obtaining data from Spotify Top Charts using spotifyr使用 spotifyr 从 Spotify Top Charts 获取数据
【发布时间】:2019-04-14 13:34:59
【问题描述】:

我正在尝试使用 R 上的 spotifyr 包获取 2017 年所有前 200 名图表的音频功能,我尝试过:

days<- spotifycharts::chartdaily()
for (i in days) {
    spotifycharts::chart_top200_daily(region = "global",days = "days[i]")
  }

在 2017 年全年每天获得前 200 名,但我无法做到。 有人能帮我吗? :(

【问题讨论】:

  • 报价中有天数。尝试删除引号:chart_top200_daily(region = "global", days = days[i])
  • 试过了,但没用...我正在尝试循环获取全年的每日前 200 名

标签: r loops spotify


【解决方案1】:

如果你将 tibble 的天数转换为向量,它会起作用:

days <- unlist(chart_daily())

lapply(days[1:3], function(i) chart_top200_daily("global", days = i))

但是它解析数据不好,所以会出现变量名等问题:

# A tibble: 6 x 5
     x1 x2                 x3      note.that.these.figures.are.generated.… x5                 
  <int> <chr>              <chr>                                     <int> <chr>              
1    NA Track Name         Artist                                       NA URL                
2     1 thank u, next      Ariana…                                 8293841 https://open.spoti…
3     2 Taki Taki (with S… DJ Sna…                                 5467625 https://open.spoti…
4     3 MIA (feat. Drake)  Bad Bu…                                 3955367 https://open.spoti…
5     4 Happier            Marshm…                                 3357435 https://open.spoti…
6     5 BAD                XXXTEN…                                 3131745 https://open.spoti…

【讨论】:

    猜你喜欢
    • 2020-06-10
    • 2016-06-26
    • 2015-01-18
    • 2021-08-11
    • 2018-02-18
    • 2019-08-01
    • 1970-01-01
    • 2023-03-24
    • 2014-04-25
    相关资源
    最近更新 更多