|
52 | 52 | #' \donttest{ |
53 | 53 | #' # Example using a line list |
54 | 54 | #' df <- epiviz::lab_data |
55 | | -#' age_sex_pyramid( |
| 55 | +#' result <- age_sex_pyramid( |
56 | 56 | #' dynamic = FALSE, |
57 | 57 | #' params = list( |
58 | 58 | #' df = df, |
59 | | -#' var_map = list(age_var = 'age', dob_var = 'date_of_birth', sex_var = 'sex'), |
| 59 | +#' var_map = list(dob_var = 'date_of_birth', sex_var = 'sex'), |
60 | 60 | #' grouped = FALSE |
61 | 61 | #' ) |
62 | 62 | #' ) |
63 | | -#' |
64 | | -#' # Example using pre-grouped data |
65 | | -#' grouped_df <- data.frame( |
66 | | -#' age_group = c("0-4", "5-18", "19-64", "65+"), |
67 | | -#' sex = c("Male", "Female"), |
68 | | -#' value = c(100, 120, 150, 80), |
69 | | -#' ci_lower = c(90, 110, 140, 70), |
70 | | -#' ci_upper = c(110, 130, 160, 90) |
71 | | -#' ) |
72 | | -#' age_sex_pyramid( |
73 | | -#' dynamic = FALSE, |
74 | | -#' params = list( |
75 | | -#' df = grouped_df, |
76 | | -#' var_map = list(age_group_var = 'age_group', sex_var = 'sex', value = 'value'), |
77 | | -#' grouped = TRUE |
78 | | -#' ) |
79 | | -#' ) |
80 | 63 | #' } |
81 | 64 | #' |
82 | 65 | #' @import ggplot2 |
@@ -112,9 +95,6 @@ age_sex_pyramid <- function( |
112 | 95 | ) |
113 | 96 | ) { |
114 | 97 |
|
115 | | - # Solve warnings regarding font family not found using utils/set_Arial() function |
116 | | - set_Arial() |
117 | | - |
118 | 98 | # Where relevant, assign defaults to any parameters not specified by the user |
119 | 99 | if(!exists('mf_colours',where=params)) params$mf_colours <- c("#440154", "#2196F3") |
120 | 100 | if(!exists('x_breaks',where=params)) params$x_breaks <- 10 |
@@ -251,6 +231,9 @@ age_sex_pyramid <- function( |
251 | 231 | }else{ |
252 | 232 | # plotly implementation of dynamic age-sex-pyramid |
253 | 233 |
|
| 234 | + # Solve warnings regarding font family not found using utils/set_Arial() function |
| 235 | + set_Arial() |
| 236 | + |
254 | 237 | # Process data similarly to static version |
255 | 238 | # plotly implementation of dynamic age-sex-pyramid |
256 | 239 | var_map <- params$var_map |
@@ -422,7 +405,7 @@ age_sex_pyramid <- function( |
422 | 405 | linecolor = "black" |
423 | 406 | ), |
424 | 407 | barmode = 'overlay', |
425 | | - font = list(family = "Arial"), |
| 408 | + font = list(family = "sans"), |
426 | 409 | hoverlabel = list(bgcolor = "white", font = list(size = 12)), |
427 | 410 | showlegend = TRUE, |
428 | 411 | legend = list(orientation = "h", |
|
0 commit comments