filter_df <- function(data, filter_list) { if (!is.list(filter_list) || is.null(filter_list) || length(filter_list) == 0) { return(data) } data <- data.table::copy(data) # filter as specified by the user for (expr in filter_list) { data <- data[eval(parse(text = expr)), ] } return(data) }
cat("\n\n##", tabtitle, "\n\n") df <- filter_df(data, filter_list) table <- eval_forecasts(df, summarise_by = summarise_by, compute_relative_skill = TRUE) if ("horizon" %in% colnames(table)) { table[, horizon := paste("horizon", horizon)] } htmltools::tagList( table %>% arrange(relative_skill) %>% dplyr::select(-scaled_rel_skill) %>% mutate_if(is.numeric, round, 2) %>% dplyr::rename(wis = interval_score, underpred = underprediction, overpred = overprediction, cvrage_dev = coverage_deviation, rel_skill = relative_skill) %>% DT::datatable(extensions = c('FixedColumns', 'Buttons'), options = list( pageLength = 10, buttons = c('csv', 'excel'), dom = 'Bfrtip', scrollX = TRUE, fixedColumns = TRUE ), class = 'white-space: nowrap') )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.