transfer_data: Transfer data between source and destination data frames.

Description Usage Arguments Details Value Author(s) Examples

View source: R/transfer_data.R

Description

Transfer data between source and destination data frames using matching of identifiers.

Usage

1
transfer_data(a1, a2, b1, b2)

Arguments

a1

name of identifier column in source data frame 'a'.

a2

name of data column in the source data frame 'a' (to be transferred to the destination data frame 'b').

b1

name of identifier column in destination data frame 'b' to be matched with a1 in data frame 'a'.

b2

(optional) name of data column in destination data frame 'b' (where data from a2 in source data frame 'a' will be transferred to).

Details

Moves data from data frame 'a' to data frame 'b'. Finds matches between column a1 and b1 and then transfers data from a2 to b2 where a1 and b1 match.

If b2 is omitted from the function argument then data from a2 will be added to a new column. If the b2 argument is used then data from a2 will be merged into existing column.

If there is ever a situation where more than one row in the source data frame has matched a row in the destination data frame and the data for transfer within those multiple rows is not all identical, then the data from the first of the matching rows will have been transferred and a warning will be issued.

Value

Returns column b2.

Author(s)

Aaron Hayman

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
friends
> 	name	occupation	birthday
> 1	bob	banker		1/2/89
> 2	tom	builder		4/6/75
> 3	ted	driver		26/7/81
family
> 	name	relation	birthday
> 1	mavis	mum		5/3/56
> 2	pete	dad		12/9/58
> 3	bob	cousin		forgotten
family$birthday = transfer(friends$name,friends$birthday,family$name,family$birthday)
family
> 	name	relation	birthday
> 1	mavis	mum		5/3/56
> 2	pete	dad		12/9/58
> 3	bob	cousin		1/2/89

jgrevel/BAST1-R-Library documentation built on May 21, 2019, 10:11 a.m.