From 8918cf4b77bb5eafe2d4de1c9b6ba271fb457c7c Mon Sep 17 00:00:00 2001 From: "Zhian N. Kamvar (UMass)" Date: Tue, 10 Dec 2024 15:37:24 -0800 Subject: [PATCH] remove comments --- vignettes/articles/scripting-tasks-config.Rmd | 64 ++++--------------- 1 file changed, 14 insertions(+), 50 deletions(-) diff --git a/vignettes/articles/scripting-tasks-config.Rmd b/vignettes/articles/scripting-tasks-config.Rmd index 95b50be..26ca76a 100644 --- a/vignettes/articles/scripting-tasks-config.Rmd +++ b/vignettes/articles/scripting-tasks-config.Rmd @@ -103,13 +103,10 @@ The `target_metadata` provides both human-readable (`target_name` and information about the targets. ```{r create-target-metadata} -# Load the hubAdmin package library(hubAdmin) -# Create a representation of a `target_metadata` item as a list object of class -# `target_metadata_item`, the `target_metadata_hosp` that will hold the -# metadata for the target of incident influenza hospitalizations + target_metadata_hosp <- create_target_metadata_item( - target_id = "inc hosp", + target = "inc hosp", target_name = "Weekly incident influenza hospitalizations", target_units = "rate per 100,000 population", target_keys = list(target = "inc hosp"), @@ -118,11 +115,8 @@ target_metadata_hosp <- create_target_metadata_item( time_unit = "week" ) -# Create a representation of a `target_metadata` item as a list object of class -# `target_metadata_item`, the `target_metadata_death`, that will hold the -# metadata for the target of incident influenza deaths target_metadata_death <- create_target_metadata_item( - target_id = "inc death", + target = "inc death", target_name = "Weekly incident influenza deaths", target_units = "rate per 100,000 population", target_keys = list(target = "inc death"), @@ -131,8 +125,6 @@ target_metadata_death <- create_target_metadata_item( time_unit = "week" ) -# Combine the `target_metadata_item` objects to create a `target_metadata` -# class object, the `target_metadata` target_metadata <- create_target_metadata(target_metadata_hosp, target_metadata_death) ``` @@ -162,7 +154,7 @@ out, the function will provide a helpful error: ```{r tmh-example} #| error: true create_target_metadata_item( - target_id = "inc hosp", + target = "inc hosp", target_name = "Weekly incident influenza hospitalizations", target_units = "rate per 100,000 population", target_keys = list(target = "inc hosp"), @@ -184,34 +176,23 @@ to 4-week-ahead predictions, and also provide predictions for the "weekly incident influenza deaths" target (`inc death`). ```{r set-task-ids} - -# Create a representation of a task ID item as a list object of `class -# task_id`, the `origin_date_id` -origin_date_id <- create_task_id( +origin_date <- create_task_id( "origin_date", required = NULL, optional = c("2023-01-02", "2023-01-09", "2023-01-16") ) -# Create a representation of a task ID item as a list object of `class -# task_id`, the `location_id` -location_id <- create_task_id( +location <- create_task_id( "location", required = "US", optional = c("01", "02", "04", "05", "06") ) -# Create a representation of a task ID item as a list object of `class -# task_id`, the `horizon_id` -horizon_id <- create_task_id("horizon", required = 1L, optional = 2:4) +horizon <- create_task_id("horizon", required = 1L, optional = 2:4) -# Create a representation of a task ID item as a list object of `class -# task_id`, the `target_id` -target_id <- create_task_id("target", required = "inc hosp", optional = "inc death") +target <- create_task_id("target", required = "inc hosp", optional = "inc death") -# Combine the `task_id` objects to create a `task_ids` class object, the -# `task_ids_example` -task_ids_example <- create_task_ids(origin_date_id, location_id, horizon_id, target_id) +task_ids_example <- create_task_ids(origin_date, location, horizon, target) ``` @@ -226,19 +207,18 @@ For this example, we want to have three output type objects: 2. a required `"quantile"` output type 3. an optional `"median"` output type - Additionally, our two targets will accept a different combination of output types. Specifically, target `"inc hosp"` will only accept `"mean"` and `"median"` output types while `"inc death"` will only accept `"mean"` and `"quantile"` output types. +Additionally, our two targets will accept a different combination of output +types. Specifically, target `"inc hosp"` will only accept `"mean"` and +`"median"` output types while `"inc death"` will only accept `"mean"` and +`"quantile"` output types. ```{r create-output-type-ids} -# Create a representation of a `mean` output type as a list object of class -# `output_type_item` mean_out_type <- create_output_type_mean( is_required = TRUE, value_type = "double", value_minimum = 0 ) -# Create a representation of a `median` output type as a list object of class -# `output_type_item` median_out_type <- create_output_type_median( is_required = FALSE, value_type = "integer", @@ -246,7 +226,6 @@ median_out_type <- create_output_type_median( ) -# Create a representation of a `quantile` output type as a list object of class `output_type_item` quantile_out_type <- create_output_type_quantile( required = c(0.25, 0.5, 0.75), is_required = TRUE, @@ -258,12 +237,8 @@ quantile_out_type <- create_output_type_quantile( Now that we have our base `output_type_item` class objects, we can combine them to create `output_type` class objects that we want to use for each particular target. ```{r combine-output-types} -# Combine the point estimate `output_type_item` objects to create an -# `output_type` class object, the `output_type_mean_median` output_type_mean_median <- create_output_type(mean_out_type, median_out_type) -# Combine the other `output_type_item` objects to create an `output_type` class -# object, the `output_type_mean_quantile` output_type_mean_quantile <- create_output_type(mean_out_type, quantile_out_type) ``` @@ -274,22 +249,18 @@ output type for the `inc death` target and an optional "median" for the `inc hosp` target. ```{r create-model-task} -#Create an object of class `model_task` representing a model task, the `model_task_hosp` model_task_hosp <- create_model_task( task_ids = task_ids_example, output_type = output_type_mean_median, target_metadata = target_metadata ) -#Create another object of class `model_task` representing a similar model task, the `model_task_death` model_task_death <- create_model_task( task_ids = task_ids_example, output_type = output_type_mean_quantile, target_metadata = target_metadata ) -# Combine the `model_task` objects to create a `model_tasks` class object, the -# `model_task_example` model_task_example <- create_model_tasks(model_task_hosp, model_task_death) ``` Now that we have a set of model tasks, we can create rounds for them. @@ -309,8 +280,6 @@ for that round are from `r paste(format(as.Date("2023-01-02") + c(-4, 2), "%A %Y-%m-%d"), collapse = " to ")` ```{r create-rounds} -# Create a representation of a round as a list object of class `round`, the -# `round1` round1 <- create_round( round_id_from_variable = TRUE, round_id = "origin_date", @@ -323,7 +292,6 @@ round1 <- create_round( ) ) -# Combine the `round` objects to create a `rounds` class object, the `rounds` rounds <- create_rounds(round1) ``` @@ -333,12 +301,8 @@ And the penultimate step is to create a config file and write it out to your hub. ```{r create-tasks, eval = FALSE} -# Create a representation of a complete `"tasks"` config file as a list object -# of class `config` config <- create_config(rounds) -# Write the `config` object to a JSON file (note that this will overwrite any -# existing file with the same name in the "hub-config" folder) write_config(config) ``` ```{r really-write} @@ -410,7 +374,7 @@ round2 <- create_round( submissions_due = list(start = "2023-01-09", end = "2023-01-16") ) two_rounds <- create_rounds(round1, round2) -new_config <- create_config(two_rounds, output_type_id_datatype = "auto") +new_config <- create_config(two_rounds) ``` ```{r create-tasks-too, eval = FALSE}