How to remove space before dot using paste() function in R

Solution 1:

Use paste0:

paste0("The values are ", a, " and ", b, ".")
"The values are 4 and 5."

or paste("The values are ", a, " and ", b, ".", sep = "")

Solution 2:

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}.")