diff --git a/R/data.R b/R/data.R index c289f56..568b65c 100644 --- a/R/data.R +++ b/R/data.R @@ -156,3 +156,21 @@ #' @source \url{https://en.wikipedia.org/wiki/Taylor_Swift_albums_discography} #' @source \url{https://www.metacritic.com/person/taylor-swift} "taylor_albums" + +#' The Eras Tour Surprise Songs +#' +#' A data set containing all of the surprise songs played on The Eras Tour +#' through the first North American leg of the tour. +#' +#' @format A [tibble][tibble::tibble-package] with `r nrow(eras_tour_surprise)` +#' rows and `r ncol(eras_tour_surprise)` variables: +#' * `leg`: The leg of the tour (e.g., North America, South America, etc.). +#' * `date`: The date of the show in ISO 8601 format (yyyy-mm-dd). +#' * `city`: The location of the show. For US shows, the location is the city +#' and state. For international shows, the location is the city and country. +#' * `night`: The show number within each city. +#' * `dress`: The color of the dress Taylor wore on the given night. +#' * `instrument`: The instrument used to play the song (guitar or piano). +#' * `song`: The track name of the song. +#' * `guest`: The special guest (if any) that joined Taylor to play the song. +"eras_tour_surprise" diff --git a/data-raw/surprise-songs.R b/data-raw/surprise-songs.R new file mode 100644 index 0000000..a325725 --- /dev/null +++ b/data-raw/surprise-songs.R @@ -0,0 +1,28 @@ +library(tidyverse) +library(readxl) +library(here) + +devtools::load_all() + +eras_tour_surprise <- read_xlsx(here("data-raw", "surprise-songs.xlsx")) %>% + mutate(date = as_date(date), + night = as.integer(night)) %>% + filter(date < today()) + +# QC data file ----------------------------------------------------------------- +# Check for track names are consistent. Should be 0 rows. +(bad_name <- eras_tour_surprise %>% + filter(!(song %in% taylor_all_songs$track_name))) + +# Check that we're using Taylor's Version when possible. Should be 0 rows. +(not_tv <- eras_tour_surprise %>% + left_join(taylor_all_songs %>% + filter(is.na(ep) | !ep) %>% + distinct(track_name, album_name), + join_by(song == track_name), + relationship = "many-to-one") %>% + filter(!is.na(album_name), + !album_name %in% taylor_album_songs$album_name) %>% + distinct(song, album_name)) + +use_data(eras_tour_surprise, overwrite = TRUE) diff --git a/data-raw/surprise-songs.xlsx b/data-raw/surprise-songs.xlsx new file mode 100644 index 0000000..96ee890 Binary files /dev/null and b/data-raw/surprise-songs.xlsx differ diff --git a/data/eras_tour_surprise.rda b/data/eras_tour_surprise.rda new file mode 100644 index 0000000..63d9522 Binary files /dev/null and b/data/eras_tour_surprise.rda differ diff --git a/man/eras_tour_surprise.Rd b/man/eras_tour_surprise.Rd new file mode 100644 index 0000000..a18db0f --- /dev/null +++ b/man/eras_tour_surprise.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data.R +\docType{data} +\name{eras_tour_surprise} +\alias{eras_tour_surprise} +\title{The Eras Tour Surprise Songs} +\format{ +A \link[tibble:tibble-package]{tibble} with 114 +rows and 8 variables: +\itemize{ +\item \code{leg}: The leg of the tour (e.g., North America, South America, etc.). +\item \code{date}: The date of the show in ISO 8601 format (yyyy-mm-dd). +\item \code{city}: The location of the show. For US shows, the location is the city +and state. For international shows, the location is the city and country. +\item \code{night}: The show number within each city. +\item \code{dress}: The color of the dress Taylor wore on the given night. +\item \code{instrument}: The instrument used to play the song (guitar or piano). +\item \code{song}: The track name of the song. +\item \code{guest}: The special guest (if any) that joined Taylor to play the song. +} +} +\usage{ +eras_tour_surprise +} +\description{ +A data set containing all of the surprise songs played on The Eras Tour +through the first North American leg of the tour. +} +\keyword{datasets} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 2b7cae6..b1793dc 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -36,6 +36,7 @@ reference: - taylor_album_songs - taylor_all_songs - taylor_albums + - eras_tour_surprise - title: Plotting - subtitle: Color palettes diff --git a/tests/testthat/test-data.R b/tests/testthat/test-data.R index 4366bb7..fca8a74 100644 --- a/tests/testthat/test-data.R +++ b/tests/testthat/test-data.R @@ -10,6 +10,9 @@ test_that("data has expected dimensions", { # albums expect_equal(ncol(taylor_albums), 5L) + # surprise songs + expect_equal(ncol(eras_tour_surprise), 8L) + albums <- unique(taylor_all_songs[which((!taylor_all_songs$ep) & !is.na(taylor_all_songs$album_name)), @@ -51,6 +54,11 @@ test_that("column names match documentation expectation", { # albums expect_equal(colnames(taylor_albums), c("album_name", "ep", "album_release", "metacritic_score", "user_score")) + + # surprise songs + expect_equal(colnames(eras_tour_surprise), c("leg", "date", "city", "night", + "dress", "instrument", "song", + "guest")) }) test_that("non-TV versions are excluded when possible", { @@ -66,3 +74,13 @@ test_that("non-TV versions are excluded when possible", { expect_false(any(exclude_albums %in% taylor_album_songs$album_name)) }) + +test_that("surprise songs are the correct version", { + expect_true(all(eras_tour_surprise$song %in% taylor_all_songs$track_name)) + + no_tv_songs <- eras_tour_surprise$song[grep("Taylor's Version", + eras_tour_surprise$song, + invert = TRUE)] + expect_false(any(paste(no_tv_songs, "(Taylor's Version)") %in% + taylor_all_songs$track_name)) +})