rtry_join_left {rtry}R Documentation

Left join for two data frames

Description

This function merges two data frames or data tables based on a specified common column and returns all records from the left data frame (x) together with the matched records from the right data frame (y), while discards all the records in the right data frame that does not exist in the left data frame. In other words, this function performs a left join on the two provided data frames or data tables.

Usage

rtry_join_left(x, y, baseOn, showOverview = TRUE)

Arguments

x

A data frame or data table to be coerced and will be considered as the data on the left.

y

A data frame or data table to be coerced and will be considered as the data on the right.

baseOn

The common column used for merging.

showOverview

Default TRUE displays the dimension and column names of the merged data.

Value

An object of the same type of the input data. The merged data is by default lexicographically sorted on the common column. The columns are the common column followed by the remaining columns in x and then those in y.

References

This function makes use of the merge function within the base package.

See Also

rtry_join_outer, rtry_bind_col, rtry_bind_row

Examples

# Assume a user has obtained two unique data tables, one with the ancillary data
# Longitude and one with Latitude (e.g. using rtry_select_anc()), and would like to
# add a column Latitude to the data table with Longitude based on the common
# identifier ObservationID
lon <- rtry_select_anc(data_TRY_15160, 60)
lat <- rtry_select_anc(data_TRY_15160, 59)

georef <- rtry_join_left(lon, lat, baseOn = ObservationID)

# Expected messages:
# dim:   97 2
# col:   ObservationID Longitude
#
# dim:   98 2
# col:   ObservationID Latitude
#
# dim:   97 3
# col:   ObservationID Longitude Latitude

[Package rtry version 1.1.0 Index]