Closed Amex-AZ closed 11 months ago
The rtf_subline
is designed to be a constant for a table. The content in each page depends on multiple factors and only determined after rtf_encode
is executed. So r2rtf
did not directly support this feature.
If you do not want to generate multiple tables and combine them, you may post-processing the information generated by rtf_code
.
Here is an example to achieve the goal.
x <- iris %>%
rtf_subline("place---holder") %>%
rtf_colheader("a|b|c|d") %>%
rtf_body(
page_by = "Species",
new_page = TRUE) %>%
rtf_encode(verbose = FALSE)
pattern <- "place---holder"
i <- 0
while(grepl(pattern,x$body, fixed = TRUE)){
i <- i + 1
x$body <- sub(pattern, glue::glue("condition in page {i}"), x$body)
}
x %>%
write_rtf("tmp.rtf")
Your logic produced the output I was looking for, thanks!
Hello! Can the rtf_subline text be adjusted dynamically dependent on page_by?
Context I have a few of pages of rft output. Each page will be based on a distinct criteria (groupn = page_by).
How can I effectively update rtf_subline(text = "condition") for each condition.
The only workable approach was to avoid using page_by and instead break and join the pages.