Open nsbatra opened 2 years ago
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)
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?
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
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?
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
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")
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
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))
time series chapter
add data.frame() around the object within all trending::fit() and predict() commands
Link fixed in iteration as per this issue
Added banner to top of every chapter by doing the following:
- [ ] 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
Cleaning page switched linelist to matchmaker in dictionary-based cleaning
Dates page guess_dates() was switched to parse_date()