I try to use the paste function to print some strings, and numeric in R such as:
method = "binomial"
b = 5
paste("The method is", a, "and the value is", b, ".")
and the result looks like
"The method is binomial and the result is 5 ."
How to remove the space between 5 and .? I want the result looks like
"The method is binomial and the value is 5."
If I am using the paste0("The method is", a, "and the value is", b, ".") the result looks like
"The method isbinomialand the result is5."
Thank you.
CodePudding user response:
Use paste0:
paste0("The values are ", a, " and ", b, ".")
"The values are 4 and 5."
or paste("The values are ", a, " and ", b, ".", sep = "")
CodePudding user response:
Paste0(...) or paste(..., sep = "") work fine, but I find the glue() offers a clean way of concatenating strings, without lots of opening and closing quotes.
In this case:
glue::glue("The values are {a} and {b}.")
