
Last chance! 50% off unlimited learning
Sale ends in
Combine data across columns. If NA is the only value across all focal columns for given row(s), NA will be returned for those row(s).
combine_data_across_cols(data = NULL, cols = NULL)
the output will be a numeric or character vector.
a data object (a data frame or a data.table)
a character vector containing names of columns, across which to combine data
dt <- data.frame(v1 = c(1, NA), v2 = c(NA, 2))
dt
combine_data_across_cols(data = dt, cols = c("v1", "v2"))
dt <- data.frame(v1 = c(1, 2, NA), v2 = c(NA, 4, 3))
dt
combine_data_across_cols(data = dt, cols = c("v1", "v2"))
dt <- data.frame(v1 = c(1, NA, NA), v2 = c(NA, 2, NA))
dt
combine_data_across_cols(data = dt, cols = c("v1", "v2"))
Run the code above in your browser using DataLab