R/songs.R

Defines functions select_powerballad

Documented in select_powerballad

#Songselector



#' Select a powerballad, randomly
#'
#' Use this function to randomly select a power ballad
#' from the list.
#'
#' @return a character vector of length 1 containing a song and artist
#' @export
#' @examples
#' select_powerballad()
select_powerballad <- function(){
    # read in latest songs
    # select a random song from ballads
    possible_values <- seq_len(nrow(powrballad::ballads))
    sample(possible_values, size = 1)
    # return a random sample
    powrballad::ballads[sample(possible_values,size = 1),]
}



# a hidden function that reads in the txt file and creates a
# new version of powerballads.rda
# ballads <- read.delim("inst/extdata/powerballads.txt", header = FALSE, skip = 1,stringsAsFactors = FALSE )
# devtools::use_data(ballads,internal = FALSE,overwrite = TRUE)
Raoke/powrballad documentation built on Sept. 10, 2017, 6:09 p.m.