I'm trying to use https://mermaid-js.github.io/mermaid/#/ to output some texts to a flowchart. This is the syntax I need to follow, which is a single quotation outside of a double quotation. For example,
library(DiagrammeR)
mermaid('graph TB \n Trial_A["<b>Trial_A </b>
<br/> (BGL + PCD vars)
<br/> (XAL)
<br/> (RAX)
<br/> (NOW)"]
\n style Trial_A fill:#FCFBFD \n ')
So I'm trying to combine a list of text using paste0
, but it's always a double quotation outside:
textn <- c("This is a sentence [<b>]", '"a (panda bear)"')
textn2 <- paste0(textn, collapse=" \n ")
textn2
"This is a sentence [<b>] \n \"a (panda bear)\""
I want
'This is a sentence [<b>] \n \"a (panda bear)\"'
Are there any ways I can do this? I tried gsub("\"","\'", textn2)
, it only changed the double quotation inside.
The noquote() is what you are after.
Run:
noquote("Your text")
You get:
Your text
Run:
paste0("'", noquote("Your text"), "'")
You get:
"'Your text'"
Run:
noquote(paste0("'", noquote("Your text"), "'"))
You then get what you want:
'Your text'