R/schedule.R

Defines functions program course_title print_session_info get_sessions

Documented in course_title get_sessions print_session_info program

#' get_sessions
#'
#' @return tibble with session info 
#' @export
#'
get_sessions <- function() {
  if(program() == 'egsh') {
    tibble::frame_data(~Session, ~Date, ~Location, ~Time,
               1, '2020-05-12', 'Online', '13:30--17:00',
               2, '2020-05-15', 'Online', '13:30--17:00',
               3, '2020-05-19', 'Online', '13:30--17:00',
               4, '2020-05-22', 'Online', '13:00--17:00') %>%
      dplyr::mutate(Date = lubridate::ymd(Date))
    # mutate(Date = coalesce(ymd(Date), ymd(Date)[1] + weeks(0:3)),
           # Time = '13.30--16.30')
  } else if(program() == 'erim') {
    tibble::frame_data(~Session, ~Date, ~Location, ~Time,
               1, '2019-07-01', 'Polak Y1--07', '09:00--12:00',
               2, NA, 'Polak Y1--07', '13:30--16:30',
               3, '2019-07-02', 'Polak Y1--07', '09:00--12:00',
               4, NA, 'Polak Y1--07', '13:30--16:30') %>%
      dplyr::mutate(Date = coalesce(lubridate::ymd(Date), lag(lubridate::ymd(Date))))
  }
}

#' print_session_info
#'
#' @param s 
#'
#' @return character string with session info
#' @export
#'
print_session_info <- function(s) {
  with(as.data.frame(get_sessions()[s,]), 
       paste0(format(Date, '%e %b'), ', ', Time, ', ', Location))
}

#' course_title
#'
#' @return
#' @export
course_title <- function() {
  if(program() == 'egsh')
    "Data visualisation, web scraping, and text analysis in R"
  else if(program() == 'erim')
    "Introduction to data visualization, web scraping, and text analysis in R"
}


#' program
#'
#' @return
#' @export
#'
program <- function() {
  'egsh' #'erim' 'egsh'
}
jasonmtroos/rook documentation built on May 24, 2020, 3:16 p.m.