txt_paste {udpipe}R Documentation

Concatenate strings with options how to handle missing data

Description

NA friendly version for concatenating string

Usage

txt_paste(..., collapse = " ", na.rm = FALSE)

Arguments

...

character vectors

collapse

a character string to be used to paste the vectors together. Defaults to a space: ' '.

na.rm

logical, if set to TRUE, will replace NA with ”. If set to FALSE, will have a resulting value of NA if at least one element is NA, in a similar spirit as mean. Defaults to FALSE.

Value

a character vector

See Also

paste

Examples

x <- c(1, 2, 3, NA, NA)
y <- c("a", "b", "c", NA, "OK")
paste(x, y, sep = "-")
txt_paste(x, y, collapse = "-", na.rm = TRUE)
txt_paste(x, y, collapse = "-", na.rm = FALSE)

x <- c(NA, "a", "b")
y <- c("1", "2", NA)
z <- c("-", "*", NA)
txt_paste(x, y, z, collapse = "", na.rm = TRUE)
txt_paste(x, y, z, "_____", collapse = "", na.rm = TRUE)
txt_paste(x, y, z, "_____", collapse = "", na.rm = FALSE)

[Package udpipe version 0.8.11 Index]