Extract a database identifier from an ID column and add it as a separate column.

add_db(
  dat,
  input_col,
  output_col = paste0(input_col, "_db"),
  split = ":",
  keep = 1
)

Arguments

dat

data.table or tbl_graph.

input_col

Column containing IDs.

output_col

Column to add.

split

character vector (or object which can be coerced to such) containing regular expression(s) (unless fixed = TRUE) to use for splitting. If empty matches occur, in particular if split has length 0, x is split into single characters. If split has length greater than 1, it is re-cycled along x.

keep

Specify indices corresponding to just those list elements to retain in the transposed result. Default is to return all.