This function adds additional data to records in a table: data on the affiliation, publication output and co-authors of records in the table.

augment_tbl(tbl, conn, with_info, on_col = "AuthorId", ...)

Arguments

tbl

A query from conn with dbplyr and lazily evaluated.

conn

An object of class SQLiteConnection to a sqlite database.

with_info

Which info should tbl be augmented with? A column vector with the following options, specified as strings:

  • affiliation: joins information on unit-year for units in on_col

  • output: joins research output on unit-year for units in on_col

  • coauthor: joins the (academic lifetime) co-authors of units in on_col

on_col

On which column should the information be joined? The default is "AuthorId", the unit of authors in MAG. Alternatively, use "CoAuthorId" to join information on co-authors (see below for details).

...

Additional arguments to be passed to make_tbl_output. If not specified, a lazily evaluated table without limit is returned. Partially specified arguments are completed with dots_tbl_output.

Value

A new tbl with the columns specified with_info added.

Details

There are two main purposes for which this function can be currently used:

  1. Join output and/or affiliation information to author units. This works directly with one call to augment_tbl.

  2. Join information on affiliations of co-authors of author units in tbl. To do this, you need to call augment_tbl twice: First, to join the co-author information of author units in tbl, and then again to join the affiliations of co-authors, using the option on_col = "CoAuthorId.

Mixing the purposes is discouraged because it creates duplicated records.

Examples

conn <- connect_to_db(db_example("AcademicGraph.sqlite"))
#> The database connection is: 
#> src:  sqlite 3.38.5 [/tmp/RtmptPxKJr/temp_libpath72cc939d74f39/magutils/extdata/AcademicGraph.sqlite]
#> tbls: AuthorAffiliation, FieldsOfStudy, FirstNamesGender, author_coauthor,
#>   author_output, current_links, current_links_advisors, pq_advisors,
#>   pq_authors, pq_fields_mag, pq_unis
graduates <- get_links(conn, from = "graduates")
graduates <- augment_tbl(graduates, conn, with_info = "output")