Skip to contents

Sources list authors in one string, separated by newlines, commas, semicolons, "and" or "&". split_author_string() returns one row per name, with its position. Name suffixes split off by a comma ("John Smith, Jr.") are not counted as authors.

Usage

split_author_string(
  doc_id,
  authors,
  pattern = "\\s*(\\n|,|;|\\band\\b|&)\\s*",
  drop_prefix = "^\\s*by\\s+"
)

Arguments

doc_id

Character. Identifier of the document of each string.

authors

Character. Author strings.

pattern

Character. Regular expression of the separators.

drop_prefix

Character. Regular expression removed at the start of each string (by default a leading "by").

Value

A data.table with doc_id, author_order and name_raw (the name as written by the source; standardising names is a later step).

Details

Commas also separate surname and first name in some sources ("Smith, John"): check the format of a source before using the default pattern, and pass a pattern without the comma if needed.

Examples

split_author_string(
  c("ecb:1", "boe:2"),
  c("by Christine Lagarde and Philip R. Lane", "Andrew Bailey, John Smith, Jr.")
)
#>    doc_id author_order          name_raw
#>    <char>        <int>            <char>
#> 1:  ecb:1            1 Christine Lagarde
#> 2:  ecb:1            2    Philip R. Lane
#> 3:  boe:2            1     Andrew Bailey
#> 4:  boe:2            2        John Smith