Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

epirhandbook_eng updates nov2022 #119

Open
nsbatra opened this issue Oct 23, 2022 · 10 comments
Open

epirhandbook_eng updates nov2022 #119

nsbatra opened this issue Oct 23, 2022 · 10 comments
Assignees
Labels
for next revision Update or addition for the next handbook revision

Comments

@nsbatra
Copy link
Contributor

nsbatra commented Oct 23, 2022

Cleaning page switched linelist to matchmaker in dictionary-based cleaning

Dates page guess_dates() was switched to parse_date()

@nsbatra nsbatra added the for next revision Update or addition for the next handbook revision label Oct 23, 2022
@nsbatra
Copy link
Contributor Author

nsbatra commented Oct 23, 2022

Also update pivoting page fill section so pivot_wider command has different id cols.

df_combined %>% 
  pivot_wider(
    id_cols = c(Measurement, Facility),
    names_from = "Year",
    values_from = "Cases"
  ) %>% 
  arrange(Facility) %>% 
  janitor::adorn_totals(c("row", "col")) %>% 
  knitr::kable() %>% 
  kableExtra::row_spec(row = 5, bold = TRUE) %>% 
  kableExtra::column_spec(column = 5, bold = TRUE) 

@nsbatra nsbatra changed the title package updates nov2022 parsedate and matchmaker epirhandbook_eng updates nov2022 Oct 23, 2022
@nsbatra
Copy link
Contributor Author

nsbatra commented Oct 23, 2022

Getting an error in the time series chapter that seems to come from the attempted use of cbind() within {trending} not being supported by {tsibble}.

@aspina7 do you know how we can fix this so that the Handbook will render?

image

@nsbatra
Copy link
Contributor Author

nsbatra commented Oct 23, 2022

More updates:
-Fixed case_when() example in data cleaning (removed last line of the command). Still needs a more relevant example and dataset revisions to do case definition.

-Survey chapter: switched plot_age_pyramid() to age_pyramid() function

@aspina7
Copy link
Contributor

aspina7 commented Oct 23, 2022

Getting an error in the time series chapter that seems to come from the attempted use of cbind() within {trending} not being supported by {tsibble}.

@aspina7 do you know how we can fix this so that the Handbook will render?

image

Yeah someone posted an issue on here. If you change to data.frame is fine.... But then you loose tsibble index. They were working on a new release of trending to address that but don't think ever finished

@nsbatra
Copy link
Contributor Author

nsbatra commented Oct 24, 2022

Fix surveys alluvial plot by changing to:

## summarize data
flow_table <- survey_data %>%
  count(startcause, endcause, sex) %>%  # get counts 
  gather_set_data(x = c("startcause", "endcause"))     # change format for plotting


## plot your dataset 
  ## on the x axis is the start and end causes
  ## gather_set_data generates an ID for each possible combination
  ## splitting by y gives the possible start/end combos
  ## value as n gives it as counts (could also be changed to proportion)
ggplot(flow_table, aes(x, id = id, split = y, value = n)) +
  ## colour lines by sex 
  geom_parallel_sets(aes(fill = sex), alpha = 0.5, axis.width = 0.2) +
  ## fill in the label boxes grey
  geom_parallel_sets_axes(axis.width = 0.15, fill = "grey80", color = "grey80") +
  ## change text colour and angle (needs to be adjusted)
  geom_parallel_sets_labels(color = "black", angle = 0, size = 5) +
  ## remove axis labels
  theme_void()+
  ## move legend to bottom
  theme(legend.position = "bottom")               

@nsbatra
Copy link
Contributor Author

nsbatra commented Nov 19, 2022

heat plots chapter:

chunk that groups and summarises agg_weeks should have ungroup(location_name, week) added to the end

chunk to expand agg_weeks should be:

# Create data frame of every possible facility-week
expanded_weeks <- agg_weeks %>% 
  tidyr::expand(location_name, week)  # expand data frame to include all possible facility-week combinations

Need to also consider re-doing the mutate replace_na bit to be for everything() not just one column

@nsbatra
Copy link
Contributor Author

nsbatra commented Nov 19, 2022

Interactive plots chapter, edit code to make agg_weeks (around like 200) to include an ungroup() function so that expand works as intended

agg_weeks <- facility_count_data %>% 
  filter(District == "Spring",
         data_date < as.Date("2020-08-01")) %>% 
  mutate(week = aweek::date2week(
    data_date,
    start_date = "Monday",
    floor_day = TRUE,
    factor = TRUE)) %>% 
  group_by(location_name, week, .drop = F) %>%
  summarise(
    n_days          = 7,
    n_reports       = n(),
    malaria_tot     = sum(malaria_tot, na.rm = T),
    n_days_reported = length(unique(data_date)),
    p_days_reported = round(100*(n_days_reported / n_days))) %>% 
  ungroup(location_name, week) %>% 
  right_join(tidyr::expand(., week, location_name)) %>% 
  mutate(week = aweek::week2date(week))

@nsbatra
Copy link
Contributor Author

nsbatra commented Nov 19, 2022

time series chapter

add data.frame() around the object within all trending::fit() and predict() commands

@nsbatra
Copy link
Contributor Author

nsbatra commented Nov 20, 2022

Link fixed in iteration as per this issue

@nsbatra
Copy link
Contributor Author

nsbatra commented May 21, 2023

Added banner to top of every chapter by doing the following:

  • Add to google.tag.html this paragraph to create the banner:

<div class="alert alert-info alert-dismissible">
  <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  <strong>Tu as besoin d'aide pour apprendre R?</strong> Inscris-toi au <a href="https://www.appliedepi.org/live/" class="alert-link">cours d'introduction à R</a> d'Applied Epi, essaie nos <a href="https://www.appliedepi.org/tutorial/" class="alert-link">tutoriels R gratuits</a>, publie dans notre <a href="https://community.appliedepi.org/" class="alert-link">forum de questions et réponses</a>, ou demande notre <a href="mailto:[email protected]" class="alert-link">assistance R</a>.
</div>

  • in output.yml add includes:in_header: [google_tab.html] as below. Be careful to do this in the BS4 bookdown section.
bookdown::bs4_book:
  includes:
    in_header: [google_tag.html]
  theme:
    primary: "#940128"  # "#637238" - original green,  "#940128" - burgundy, 
  css: style_bs4.css
  split_by: "none"
  params:
    run_page_ind: FALSE
  #download: ["pages/handbook_combined.html"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for next revision Update or addition for the next handbook revision
Projects
None yet
Development

No branches or pull requests

3 participants