#' Concatenate strings
#'
#' Concatenate two strings (scalar character values) together, and
#' automatically separate them by a single space.
#'
#' @name op-concat
#'
#' @param x,y `[character(1)]`
#'
#' Strings to be concatenated.
#'
#' @returns A `character(1)` composed of `x` and `y` separated by a space.
#'
#' @examples
#' identical("My name is" %+% "Foo Baz.", "My name is Foo Baz.") # TRUE
#'
#' @export
`%+%` <- function(x, y)
{
if (!is_scalar_chr(x) || !is_scalar_chr(y)) {
ui_stop(
"both {.arg x} and {.arg y} must be {.code character(1)}.",
ui_todo("Be explicit, and first convert these arguments with {.fun base::as.character}."))
}
return(sprintf("%s %s", x, y))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.