Skip to contents

melt a vector into single value

Usage

melt_vector(x, method = "first", invalid = NA)

Arguments

x

vector

method

how to melt, should be one of first|last, or one of sum|mean|median for numeric vector, or some characters (e.g. ,|.| |;) for character vector

invalid

invalid value to ignore, NA as default

Value

melted single value

Examples


melt_vector(c(NA, 2, 3), method = "first")
#> [1] 2

melt_vector(c(NA, 2, 3), method = "sum")
#> [1] 5

melt_vector(c(NA, 2, 3), method = ",")
#> [1] "2,3"

melt_vector(c(NA, 2, Inf), invalid = c(NA, Inf))
#> [1] 2