lookup: Look up individual-associated data from one dataset and...

Description Usage Arguments Examples

View source: R/script - base tools.R

Description

Similar to merge(), but more flexible (and slower). Supports renaming of columns and overwrite-controll. Returns the "to" dataframe with new columns from "from" added.

Usage

1
lookup(to, from, what, by, by.x, by.y, new_name, default = NA, overwrite = F)

Arguments

to

A data frame (x) you want to add data from another set into

from

The data (y) frame you want to obtain this data from

what

Which columns from y to look up into x. Single chr value or vector with multiple values. Will take all columns from y if unspecified.

by

Which column to use for identifying individuals. The function only adds data to columns with matching identifiers.

by.x

If the identifier has a different column name in the "to" dataset, specify it with by.x

by.y

If the identifier has a different column name in the "from" dataset, specify it with by.y

new_name

If you want to rename some columns from y before inserting into x. Must be same length as "what". Use an empty "" for columns to stay the same.

default

If inserted columns doesn't exist yet in x, use this to specify the default value in case some rows can't be looked up

overwrite

If there is already a value in x where one is to be inserted from y, use this to specify if it should be overwritten or not

Examples

1
all_people = lookup(to=all_people, from=phone_book, what=c("phone_number","adress"), new_name=("mobile", ""), by="name", by.x="Name", default="not found")

Eiriksen/fishytools documentation built on April 4, 2020, 5:08 a.m.