You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we need to isolate deaths from the outcomes variable that includes deaths and recoveries
library(simulist)
library(linelist)
library(incidence2)
library(cfr)
library(tidyverse)
# run this together --------------------
set.seed(111)
dat<- sim_linelist() %>%
as_tibble()
# run this together --------------------
challenge (or assessment)
from a tidy {linelist} to {incidence2} and {cfr}
learning outcome: recognize the “tidy data” framework in a linelist
known outcome (recovered, death) in one column only
temporal states (quarantine, UCI, hospitalization) w/admision and discharge
dat %>%
dplyr::select(id, date_onset, outcome,date_outcome) %>%
# [key] data wrangling step ---------------------------------------------------# isolate deaths from outcomesdplyr::mutate(
date_death=dplyr::case_when(
outcome=="died"~date_outcome,
TRUE~NA_Date_
)
) %>%
# [end] of key data step ------------------------------------------------------linelist::make_linelist(
id="id",
date_onset="date_onset",
date_death="date_death"
) %>%
linelist::validate_linelist() %>%
linelist::tags_df() %>%
incidence2::incidence(date_index= c("date_onset","date_death")) %>%
cfr::prepare_data(
cases_variable="date_onset",
deaths_variable="date_death"
) %>%
dplyr::as_tibble()
#> NAs in cases and deaths are being replaced with 0s: Set `fill_NA = FALSE` to prevent this.#> # A tibble: 294 × 3#> date deaths cases#> <date> <int> <int>#> 1 2023-01-01 0 1#> 2 2023-01-02 0 0#> 3 2023-01-03 0 0#> 4 2023-01-04 0 0#> 5 2023-01-05 0 0#> 6 2023-01-06 0 0#> 7 2023-01-07 0 0#> 8 2023-01-08 0 0#> 9 2023-01-09 0 0#> 10 2023-01-10 0 0#> # ℹ 284 more rows
Ā
#> Error in eval(expr, envir, enclos): object 'Ā' not found
we need to isolate
deaths
from theoutcomes
variable that includes deaths and recoverieschallenge (or assessment)
from a tidy {linelist} to {incidence2} and {cfr}
learning outcome: recognize the “tidy data” framework in a linelist
Ā #> Error in eval(expr, envir, enclos): object 'Ā' not found
Created on 2024-09-29 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: