takes a dataframe with one row per show-song and reshapes it long again so that the rows are identified by combinations of gid, song_number, and alt.
Source:R/Repeatr_2.R
Repeatr_2.RdThe first line of the data this was originally developed with:
washington-dc-usa-90387 FLS0001 03/09/1987 Wilson Center $5 300 Joey Picuri Fugazi Cassette Joe #1 Intro Song #1 Furniture Merchandise Turn Off Your Guns In Defense Of Humans Waiting Room The Word
"gid" is short for "gig id"
Usage
Repeatr_2(
mydf = NULL,
mysongidlookup = NULL,
min_song_count = 2,
input_dir = NULL,
output_dir = NULL
)Arguments
- mydf
optional dataframe to be used (the
Repeatr1element ofRepeatr_1()'s return list). If omitted the default (currently lazy-loaded)Repeatr1dataframe will be used.- mysongidlookup
optional
songidlookupdataframe to be used (thesongidlookupelement ofRepeatr_1()'s return list). If omitted the default (currently lazy-loaded)songidlookupdataframe will be used. Pass this explicitly - rather than relying on the default - when callingRepeatr_2()right after a freshRepeatr_1()in the same session, since the lazy-loaded default reflects the last build on disk, not the one just computed.- min_song_count
Minimum number of performances a song needs to compete as an alternative in the choice model (
Repeatr_4). Songs performed fewer times still appear insongid/titleon the output, they just won't get analtand can't be chosen as an alternative. Default 2 - songs performed only once can't support a stable alternative-specific intercept in the choice model. This is a choice-model concern only: it does not affectsongid, whichRepeatr_1assigns to every classified song regardless of this threshold.- input_dir
Optional directory to write the
fugazi_song_counts.csv/fugazi_song_performance_intensity.csvoutput-export CSVs into. If omitted, defaults to this package's owninst/extdata(these are Repeatr's own downloadable outputs, not primary/raw data).- output_dir
Optional directory to save the rebuilt
data/*.rdaobjects into. If omitted, defaults todata/under the current working directory.
Value
A list of 3 elements: Repeatr2, a data frame with one row per gid/song_number/alt combination, prepared for choice modelling (case is the choice-situation id, alt a dense 1..n index over the min_song_count-eligible songs only - this is what mlogit/Repeatr_4 actually sees - songid the stable, full identity from songidlookup kept alongside alt rather than overwritten by it, choice whether that song was the one played, availability/played dummy variables, and years-since-launch bucket variables); altlookup (alt, songid, title, count - one row per min_song_count-eligible song), needed by Repeatr_5/rankr to translate mlogit's alt-indexed coefficients back to song identity; and fugazi_song_performance_intensity (min_song_count-eligible songs only), needed by Repeatr_5 - returned explicitly (not just saved to disk) so a fresh Repeatr_Updatr() run can thread it through rather than falling back to a stale lazy-loaded binding. Also saved to data/Repeatr2.rda and data/altlookup.rda, alongside fugazi_song_counts (which covers every classified song, not just the min_song_count-eligible ones).
Examples
Repeatr_2_results <- Repeatr_2(mydf = Repeatr1, output_dir = tempdir(), input_dir = tempdir())
#> Joining with `by = join_by(songid)`
#> Joining with `by = join_by(alt)`
#> Joining with `by = join_by(alt)`
#> Joining with `by = join_by(songid)`
#> Joining with `by = join_by(gid, alt)`
#> Joining with `by = join_by(alt)`
#> Joining with `by = join_by(alt)`
#> Joining with `by = join_by(gid, song_number)`
Repeatr2 <- Repeatr_2_results[[1]]
altlookup <- Repeatr_2_results[[2]]
fugazi_song_performance_intensity <- Repeatr_2_results[[3]]