combine_data_sources: Combine data sources

Description Usage Arguments Details Value

View source: R/combine_data_sources.R

Description

The function merges data from different columns in a pre-defined preferred order.

Usage

1
combine_data_sources(mytable, new_column_name = "new", order_of_preference)

Arguments

mytable

(required) A dataframe with all variables (columns) you would like to combine.

new_column_name

(optional) The name of the new column that will created that has incorporated data from other columns.

order_of_preference

(required) A character vector with the names of the columns you would like to merge, in the order of preference (so the first column will be added first).

Details

This function is useful if you have the same type of information from different sources, which you would like to combine in a new column. For example, if you have water depth measured on board the ship, water depth taken from high resolution bathymetry, and water depth taken from low resolution bathymetry. As the water depth from the ship is most reliable, all available data is copied into the new column. Then, all observations that remain empty (so water depth was not measured on board), are filled with corresponding data from the high resolution bathymetry column because it has a higher confidence than the low resolution bathymetry dataset. Then, if still empty fields remain, these fields are filled with information from the low resolution bathymetery column.

Value

This function returns the input table with an extra column with the name you provided.


dswdejonge/TripleD documentation built on June 18, 2020, 12:24 p.m.