join_tables: Join two layers

View source: R/fct_join_tables.R

join_tablesR Documentation

Join two layers

Description

Perform an inner join or left join operation on two layers based on n number of primary and foreign keys. Perform joins using dplyr's inner_join and left_join functions.

Usage

join_tables(f_left, f_right, j_type, pk, fk)

Arguments

f_left

layer with primary keys and left table in joins.

f_right

layer with foreign keys and right table in joins. For non-spatial joins this must be a non-spatial data frame - if it is a spatial data frame (i.e. of class sf) it will be converted to non-spatial.

j_type

a string specifying the type of join to perform. "col_inner" specifies an inner join and "col_left" specifies a left join.

pk

a character vector of primary keys. The primary and foreign keys do not need to have the same names but the order of the keys matters.

fk

a character vector of foreign keys. The primary and foreign keys do not need to have the same names but the order of the keys matters.

Details

Primary and foreign keys are converted to character vectors before joining.

Value

j_df A layer joined on primary and foreign keys. Will be of class sf(i.e. spatial features) if f_left is spatial. Otherwise returns a data frame.


livelihoods-and-landscapes/maplandscape documentation built on March 20, 2023, 5:43 a.m.