#' wrapper function on paste() that replaces NA with ""
#'
#' wrapper function on paste() that replaces NA with ""
#' @keywords paste NA
#' @export
#' @examples
#' paste_sans_NA(c(1,2,NA), c(1,NA, NA), sep = "_")
paste_sans_NA <- function(..., sep = " ") {
L <- list(...)
L <- lapply(L, function(x) {x[is.na(x)] <- ""; x})
ret <- gsub(paste0("(^", sep, "|", sep, "$)"), "",
gsub(paste0(sep, sep),sep,
do.call(paste,c(L,list(sep=sep)))))
is.na(ret) <- ret == ""
ret
}
# h/t 42- in https://stackoverflow.com/questions/13673894/suppress-nas-in-paste
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.