syntactic.make_names

syntactic.make_names(obj: list[str] | str, unique: bool = True, smart: bool = False) list[str]

Make syntactically valid names out of character vectors.

Emulates R’s syntactic::makeNames() behavior.

Parameters:
  • obj (list of str or str) – String(s) to sanitize.

  • unique (bool) – Make the returned names unique by appending numeric suffixes to duplicates.

  • smart (bool) – Handle complicated special cases, such as ampersands, plus/minus, percentages, and slashes, before generic sanitization.

Returns:

Syntactically valid name(s).

Return type:

list of str

Examples

>>> make_names(["%GC", "1st sample", "hello world"])
['GC', 'X1st_sample', 'hello_world']