Skip to contents

Add ids.

Usage

text_id_with_break(x, brk, end_with_brk = TRUE)

add_text_id_df(df, col, brk, end_with_brk = TRUE)

Arguments

x

A string vector.

brk

A string to specify the break between ids.

end_with_brk

A logical. TRUE: brk means the end of groups. FALSE: brk means the beginning of groups.

df

A dataframe.

col

A string to specify the column.

Value

id_with_break() returns id vector, add_id_df() returns dataframe.

Examples

tmp <- c("a", "brk", "b", "brk", "c")
brk <- "brk"
text_id_with_break(tmp, brk)
#> [1] 1 1 2 2 3
add_text_id_df(tibble::tibble(tmp), col = "tmp", "brk")
#> # A tibble: 5 × 2
#>   tmp   text_id
#>   <chr>   <dbl>
#> 1 a           1
#> 2 brk         1
#> 3 b           2
#> 4 brk         2
#> 5 c           3