It think it's more than that. @ beeju is using canned functions.
The function they mention, plot_missing_dates() looks like this:
plot_missing_dates
function (data, dates = Date, values = Value, groups = STATION_NUMBER,
station_number, roll_days = 1, roll_align = "right", water_year_start = 1,
start_year, end_year, months = 1:12, include_title = FALSE,
plot_type = "tile")
{
if (missing(data)) {
data <- NULL
}
if (missing(station_number)) {
station_number <- NULL
}
if (missing(start_year)) {
start_year <- 0
}
if (missing(end_year)) {
end_year <- 9999
}
plot_type <- plot_type[1]
if (!any(c("tile", "bar") %in% plot_type))
stop("plot_type must be one of 'tile' or 'bar' plots.",
call. = FALSE)
logical_arg_check(include_title)
flow_data <- flowdata_import(data = data, station_number = station_number)
flow_data <- format_all_cols(data = flow_data, dates = as.character(substitute(dates)),
values = as.character(substitute(values)), groups = as.character(substitute(groups)),
rm_other_cols = TRUE)
flow_summary <- screen_flow_data(data = flow_data, roll_days = roll_days,
roll_align = roll_align, water_year_start = water_year_start,
start_year = start_year, end_year = end_year, months = months,
include_symbols = FALSE)
if (plot_type == "bar") {
missing_plotdata <- flow_summary[, c(1, 2, 11:ncol(flow_summary))]
missing_plotdata <- tidyr::gather(missing_plotdata, Month,
Value, 3:ncol(missing_plotdata))
missing_plotdata <- dplyr::mutate(missing_plotdata, Month = substr(Month,
1, 3))
missing_plotdata$Month <- factor(missing_plotdata$Month,
levels = month.abb[c(water_year_start:12, 1:water_year_start -
1)])
miss_plots <- dplyr::group_by(missing_plotdata, STATION_NUMBER)
miss_plots <- tidyr::nest(miss_plots)
miss_plots <- dplyr::mutate(miss_plots, plot = purrr::map2(data,
STATION_NUMBER, ~ggplot2::ggplot(data = ., ggplot2::aes(x = Year,
y = Value)) + ggplot2::geom_bar(colour = "cornflowerblue",
fill = "cornflowerblue", na.rm = TRUE, stat = "identity") +
ggplot2::facet_wrap(~Month, ncol = 3, scales = "fixed",
strip.position = "top") + ggplot2::ylab("Missing Days") +
ggplot2::xlab(ifelse(water_year_start == 1, "Year",
"Water Year")) + ggplot2::theme_bw() + ggplot2::scale_y_continuous(limits = c(0,
32)) + {
if (include_title & .y != "XXXXXXX")
ggplot2::ggtitle(paste(.y))
} + ggplot2::theme(panel.border = ggplot2::element_rect(colour = "black",
fill = NA, size = 1), panel.grid = ggplot2::element_line(size = 0.2),
axis.title = ggplot2::element_text(size = 12),
axis.text = ggplot2::element_text(size = 10),
plot.title = ggplot2::element_text(hjust = 1,
size = 9, colour = "grey25"), strip.background = ggplot2::element_blank(),
strip.text = ggplot2::element_text(hjust = 0,
face = "bold", size = 10))))
}
else if (plot_type == "tile") {
missing_plotdata <- dplyr::select(flow_summary, c(1:2,
11:ncol(flow_summary)))
missing_plotdata <- tidyr::pivot_longer(missing_plotdata,
-(1:2), names_to = "Month", values_to = "Missing")
missing_plotdata <- dplyr::mutate(missing_plotdata, Month = factor(substr(Month,
1, 3), levels = rev(month.abb[c(water_year_start:12,
1:water_year_start - 1)])), Days = lubridate::days_in_month(paste(Year,
match(Month, month.abb), 1, sep = "-")), Percent_Missing = Missing/Days *
100)
miss_plots <- dplyr::group_by(missing_plotdata, STATION_NUMBER)
miss_plots <- tidyr::nest(miss_plots)
miss_plots <- dplyr::mutate(miss_plots, plot = purrr::map2(data,
STATION_NUMBER, ~ggplot2::ggplot(data = ., ggplot2::aes(x = Year,
y = Month)) + ggplot2::geom_tile(ggplot2::aes(fill = Percent_Missing),
colour = "black") + ggplot2::scale_x_continuous(expand = c(0,
0)) + ggplot2::scale_y_discrete(expand = c(0,
0), limits = rev(levels(month.abb))) + ggplot2::scale_fill_viridis_c(direction = -1,
name = "Missing\nDays (%)") + ggplot2::ylab("Month") +
ggplot2::xlab(ifelse(water_year_start == 1, "Year",
"Water Year")) + ggplot2::theme(axis.title.y = ggplot2::element_blank())))
}
plots <- miss_plots$plot
if (nrow(miss_plots) == 1) {
names(plots) <- "Missing_Dates"
}
else {
names(plots) <- paste0(miss_plots$STATION_NUMBER, "_Missing_Dates")
}
plots
}
<bytecode: 0x56c5eacf8d30>
<environment: namespace:fasstr>
I understand the problem of figuring out what that function is doing.