Skip to content

Commit

Permalink
fix: Monkey patch for gridtext@v0.1.5
Browse files Browse the repository at this point in the history
Needed to preserve the ` ` in SVG output.

Connects with <wilkelab/gridtext#38>.
  • Loading branch information
zmughal committed Dec 2, 2024
1 parent 192133a commit 6d2789e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions analysis/ctgov.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pacman::p_load(
broom,
tidyr,
assertthat,
testthat,
fs,
glue,
listr,
Expand Down
18 changes: 18 additions & 0 deletions analysis/ctgov/plot_stacked_chart.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@

#### Plot stacked chart of intervals {{{
###
###

# Local override of str_squish to preserve &nbsp;
local_str_squish <- function(string) {
stringi::stri_trim_both(stringr::str_replace_all(string, '[[\\s]-[\u00A0]]+', " "))
}

orig.str_split <- stringr::str_split
local_str_split <- function (string, pattern, n = Inf, simplify = FALSE) {
if( pattern == "[[:space:]]+" ) {
pattern <- "[[:space:]-[\u00A0]]+"
}
orig.str_split(string, pattern, n, simplify)
}

categorize_intervals <- function(interval_length, breakpoints) {
label_incomplete <- as.character(
Expand Down Expand Up @@ -99,6 +114,9 @@ plot.windows.stacked.chart <-
list_rbind()

fig.result_reported_within.stacked_area <- {
# Cleaner than `assignInNamespace`
local_mocked_bindings(str_squish = local_str_squish, .package = 'stringr')
local_mocked_bindings(str_split = local_str_split, .package = 'stringr')
df <-
windows.result_reported_within |>
mutate(
Expand Down
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
pacman parsedate patchwork purrr
readr rlang RPostgres
scales stringr survival survminer svglite
this_path tidyr tidyverse
testthat this_path tidyr tidyverse
vroom
yaml
];
Expand Down

0 comments on commit 6d2789e

Please sign in to comment.