find.id.col: Find which column in a dataframe contains a specified set of...

Description Usage Arguments Value Author(s) Examples

View source: R/reader.R

Description

Starting with a list of ids, each column is searched. The column with the highest non-zero percentage matching is assumed to correspond to the id list. The search terminates early if a perfect match is found. Useful for assembling annotation from multiple sources.

Usage

1
find.id.col(frame, ids, ret = c("col", "maxpc", "index", "result"))

Arguments

frame

a data.frame, or similarly 2 dimensional object which might contain ids

ids

a vector of IDs/value that might be found in at least 1 column of frame

ret

specify what should be returned, see values

Value

ret can specify a list returning, 'col': the column number (col=0 for rownames) with the best match; 'maxpc': the percentage of ids found in the best matching column; 'index': the matching vector that maps the frame rows onto ids; 'results': the (sub)set of ids found in frame. NAs given for ids not found

Author(s)

Nicholas Cooper nick.cooper@cimr.cam.ac.uk

Examples

1
2
3
new.frame <- data.frame(day=c("M","T","W"),time=c(9,12,3),staff=c("Mary","Jane","John"))
staff.ids <- c("Mark","Jane","John","Andrew","Sally","Mary")
new.frame; staff.ids; find.id.col(new.frame,staff.ids)

reader documentation built on May 2, 2019, 9:27 a.m.