augment_tbl: Augment a table with additional columns.

View source: R/augment_tbl.R

augment_tblR Documentation

Augment a table with additional columns.

Description

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

Usage

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.

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.

Value

A new tbl with the columns specified with_info added.

Examples

conn <- connect_to_db(db_example("AcademicGraph.sqlite"))
graduates <- get_links(conn, from = "graduates")
graduates <- augment_tbl(graduates, conn, with_info = "output")


f-hafner/magutils documentation built on Sept. 20, 2023, 5:05 a.m.