Skip to content

Is there a way to display a string with multiple \n in it (coming from external function) in fpar? #511

Closed Answered by davidgohel
Generalized asked this question in Q&A
Discussion options

You must be logged in to vote
library(officer)
text <- "aa\nbb\ncc\ndd"
parts <- stringr::str_split(text, "\n")[[1]]

parts_lst <- list()
i <- 1
for(s in parts) {
  
  parts_lst[[i]] <- s
  i <- i+1
  parts_lst[[i]] <- run_linebreak()  # doesn't work
  i <- i+1
}  

read_docx() |> 
  body_add_fpar(do.call(fpar,parts_lst)) |> 
  print(target = "test.docx")

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@davidgohel
Comment options

Answer selected by Generalized
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants