Paste which can ignore NA and empty strings
paste2.Rd
Acts the same as regular paste, unless na.rm = TRUE, in which case empty strings and NA are removed.
Details
Due to the contents of vectors passed to this function, elements in vectors may be removed without warning. Sometimes, even the whole vector is omitted. see @examples.
Examples
s1 = c("","a",NA,TRUE)
s2 = c("b","",NA,NULL)
s3 = c(NULL,NA)
paste(s1, s2, s3, sep = ',', collapse = "/")
#> [1] ",b,NA/a,,NA/NA,NA,NA/TRUE,b,NA"
paste(s1, s2, s3, sep = ',', collapse = "/", na.rm = TRUE)
#> [1] ",b,NA,TRUE/a,,NA,TRUE/NA,NA,NA,TRUE/TRUE,b,NA,TRUE"
paste2(s1, s2, s3, sep = ',', collapse = "/")
#> [1] "a,b/TRUE,b"
paste2(s1, s2, s3, sep = ',', collapse = "/", na.rm = TRUE)
#> [1] "a,b/TRUE,b"