Skip to content
Merged
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
16 changes: 8 additions & 8 deletions R/PRISMA_flowdiagram.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ PRISMA_flowdiagram <- function( #nolint
paste(
paste(
"\n",
other_excluded[, 1],
PRISMA_escape_text_(other_excluded[, 1]),
" (n = ", other_excluded[, 2], ")",
sep = ""
),
Expand Down Expand Up @@ -375,7 +375,7 @@ PRISMA_flowdiagram <- function( #nolint
paste(
paste(
"\n",
dbr_excluded[, 1],
PRISMA_escape_text_(dbr_excluded[, 1]),
" (n = ", dbr_excluded[, 2], ")",
sep = ""
),
Expand Down Expand Up @@ -1447,7 +1447,7 @@ PRISMA_data <- function(data) { #nolint
)
dbr_excluded <- data.frame(
reason = gsub(
",.*$",
",\\s*\\d+\\s*$",
"",
unlist(
strsplit(
Expand All @@ -1464,8 +1464,8 @@ PRISMA_data <- function(data) { #nolint
)
),
n = gsub(
".*,",
"",
"^.*,\\s*(\\d+)\\s*$",
"\\1",
unlist(
strsplit(
as.character(
Expand Down Expand Up @@ -1493,7 +1493,7 @@ PRISMA_data <- function(data) { #nolint
)
other_excluded <- data.frame(
reason = gsub(
",.*$",
",\\s*\\d+\\s*$",
"",
unlist(
strsplit(
Expand All @@ -1510,8 +1510,8 @@ PRISMA_data <- function(data) { #nolint
)
),
n = gsub(
".*,",
"",
"^.*,\\s*(\\d+)\\s*$",
"\\1",
unlist(
strsplit(
as.character(
Expand Down
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Utility functions for PRISMA_flowdiagram

#' Escape special characters for DOT syntax
#' @keywords internal
PRISMA_escape_text_ <- function(text) { #nolint
if (is.null(text)) return(text)
text <- as.character(text)
# Escape backslashes first, then quotes and apostrophes
text <- gsub("\\", "\\\\", text, fixed = TRUE)
text <- gsub('"', '\\"', text, fixed = TRUE)
text <- gsub("'", "\\'", text, fixed = TRUE)
return(text)
}

#' Calculate the correct height of a box from a list (e.g. of exclusion reasons)
#' @description Get the correct height for a box
#' @param n the number of rows of text in the label
Expand Down