= # add variable for weeks since 100th case and 10th death cv_cases $weeks_since_case100 = cv_cases $weeks_since_death10
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
= # add variable for weeks since 100th case and 10th death cv_cases $weeks_since_case100 = cv_cases $weeks_since_death10
= # add variable for weeks since 100th case and 10th death cv_cases $weeks_since_case100 = cv_cases $weeks_since_death10 = 0 for (i in 1:length(unique (cv_cases $country))) { country_name = as. character (unique(cv_cases $country country_db subset (cv_cases, country==country_name) country_db$weeks_since_case100 [country_db$cases >=100] = 0:(sum(country_db$cases >=100)-1) country_db $weeks_since_death10 [country_db$deaths>=10] = 0:(sum(country_db$deaths>=10)-1) cv_cases $weeks_since_case100 [cv_cases $country==country_name] country_db$weeks_since_case100 cv_cases $weeks_since_death10[cv_cases $country==country_name] country_db$weeks_since_death10 }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!