knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", eval=FALSE ) library(bbcharts)
bbcharts
provides an interface to the Billboards top charts. There is functionality for accessing weekly charts, annual charts, and the decade end data is exported as an object bbcharts::decade_end
.
You can install the latest version of bbcharts from GitHub with:
remotes::install_github("josiahparry/bbcharts")
count(bbcharts::decade_end, artist, sort = TRUE)
View all possible year end charts with ye_chart_table
bbcharts::ye_chart_table
Identify which chart you would like then pass along that chart_url
to year_end_bb()
and the year you would like it for. Due to slight inconsistencies between charts, i.e. album, artist, and song charts, the artist and title fields may be swapped around.
year_end_bb("hot-100-songs", 1960)
You can retrieve weekly charts in a very similar manner as the yearly charts. To view the weekly charts use bbcharts::chart_table
chart_table
Provide the name of the chart you want and the week you want it for in yyyy-mm-dd
format.
bb_chart("hot-100", "2017-12-10")
Use bbcharts
in conjunction with genius
to get the lyrics for songs on the top charts.
library(dplyr) library(genius) alt <- bb_chart("alternative-songs") alt_lyrics <- alt %>% # get only the first 5 songs slice(1:5) %>% # add lyrics to a data frame add_genius(artist, title, type = "lyrics") alt_lyrics
You can view all possible charts to query from using the chart_table
that is exported.
bbcharts::chart_table
There are a number of functions that provide Billboard chart data for a specific artist.
It is possible to list all of the charts that a given artist appears on using list_artist_charts()
.
list_artist_charts("Andrew Bird")
Using the information above we can list all of the songs on a chart from a given artist using get_artist_chart_history()
. In this case we will look at Triple A Songs (adult alternative).
get_artist_chart_history("Andrew Bird", "triple-a")
We can use the add_chart_history()
function in conjunction with list_artist_charts()
to get all chart history for an artist.
list_artist_charts("Andrew Bird") %>% add_chart_history(artist = artist, chart_url = chart_url)
You can also do this for any mix of artists.
tribble( ~artist, ~chart, "Andrew Bird", "triple-a", "Taylor Swift", "hot-100" ) %>% add_chart_history(artist, chart)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.