Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions R/autoplot.summary.seroincidence.by.bar.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#' Create bar plot for stratified seroincidence results
#'
#'
#' @return a [ggplot2::ggplot()] object

autoplot.seroincidence.by.bar <- function(est_country_agedf, ageCat, incidence.rate, Country, CI.lwr, CI.upr, country_pal) {

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=62,[object_name_linter] Variable and function name style should match snake_case or symbols.

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=70,[object_name_linter] Variable and function name style should match snake_case or symbols.

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 124 characters.

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=86,[object_name_linter] Variable and function name style should match snake_case or symbols.

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=95,[object_name_linter] Variable and function name style should match snake_case or symbols.

Check warning on line 6 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=6,col=103,[object_name_linter] Variable and function name style should match snake_case or symbols.
ggplot(est_country_agedf,
aes(
y = fct_rev(ageCat),

Check warning on line 9 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=9,col=16,[object_usage_linter] no visible global function definition for 'fct_rev'
x = incidence.rate * 1000, #rescale incidence
fill = Country
)) +
geom_bar(stat = "identity",

Check warning on line 13 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=13,col=5,[object_usage_linter] no visible global function definition for 'geom_bar'
position = position_dodge2(reverse = TRUE),

Check warning on line 14 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=14,col=25,[object_usage_linter] no visible global function definition for 'position_dodge2'

Check warning on line 14 in R/autoplot.summary.seroincidence.by.bar.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/autoplot.summary.seroincidence.by.bar.R,line=14,col=25,[object_usage_linter] no visible global function definition for 'position_dodge2'
show.legend = TRUE) +
geom_errorbar(
aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000), #rescale CIs
position = position_dodge2(reverse = TRUE)
) +
labs(title = "Enteric Fever Seroincidence by Country and Age",
x = "Seroincidence rate per 1000 person-years",
y = "Age Category",
fill = "Country") +
theme_linedraw() +
theme(axis.text.y = element_text(size = 11),
axis.text.x = element_text(size = 11)) +
scale_x_continuous(expand = c(0, 10)) +
scale_fill_manual(values = country_pal)

Check warning on line 28 in R/autoplot.summary.seroincidence.by.bar.R

View check run for this annotation

Codecov / codecov/patch

R/autoplot.summary.seroincidence.by.bar.R#L7-L28

Added lines #L7 - L28 were not covered by tests
}
15 changes: 8 additions & 7 deletions vignettes/articles/enteric_fever_example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ output:
toc: true
vignette: >
%\VignetteIndexEntry{Enteric Fever Seroincidence Vignette}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{knitr::rmarkdown}
bibliography: ../references.bib
editor_options:
chunk_output_type: console
---
## Introduction

Expand Down Expand Up @@ -154,9 +156,9 @@ We see that across countries, our data is highly skewed with the majority of res

xs_data %>%
mutate(Country = fct_relevel(Country, "Bangladesh", "Pakistan", "Nepal")) %>%
autoplot(strata = "Country", type = "density") +
autoplot(strata = "Country", type = "density", log = TRUE) +
scale_fill_manual(values = country_pal) +
scale_x_log10(labels = scales::label_comma())
labs(x = "Log Antibody Response Value")

```

Expand Down Expand Up @@ -281,15 +283,14 @@ ggplot(est_country_agedf,
fill = Country
)) +
geom_bar(stat = "identity",
position = position_dodge(),
position = position_dodge2(reverse = TRUE),
show.legend = TRUE) +
geom_errorbar(
aes(xmin = CI.lwr * 1000, xmax = CI.upr * 1000), #rescale CIs
position = position_dodge(width = 0.9),
width = .2
position = position_dodge2(reverse = TRUE)
) +
labs(title = "Enteric Fever Seroincidence by Country and Age",
x = "Seroincidence rate per 1000 person-years",
x = "Seroconversion rate per 1000 person-years",
y = "Age Category",
fill = "Country") +
theme_linedraw() +
Expand Down
Loading