For example index_sep('a_b_c', 2, '_') equals 'b'. For example index_sep('a_b_c', c(1, 3), '_') equals 'a_c'. For example index_sep('a_b_c', -2, '_') equals 'a_c'. For example index_sep('a_b_c', 4, '_') equals ''. For example index_sep('a', 1, '_') equals 'a'. For example index_sep('a', 2, '_') equals ''. For example index_sep(c('a_b', 'c'), 2, '_') equals c('b', ''). For example index_sep('a_b_c', c(3, 1), '_') equals 'c_a'.

index_sep(x, i, sep = "_", complement = FALSE)

Arguments

x

character vector

i

integer vector without sign mixing

sep

length-one character vector

complement

if TRUE the indices in i that are not matched are returned