consolidateCols: Create dosage and units columns

Description Usage Arguments Details Value

Description

Given items data, with columns 'hash_str', 'title', 'prediction', 'grams', 'ounces', 'pounds', 'milligrams', 'pills', 'quantity', consolidate these into 'dosage' and 'unit', where dosage is e.g. "100mg", and unit is some number, e.g. 30 for 30 pills, or 10 for "10 credit cards."

Usage

1
consolidateCols(itemsTuple)

Arguments

itemsTuple

name of dataframe with items data, described above

Details

For dosage, we first choose the first available value of grams, ounces, pounds and milligrams. Then we process the raw text (change comma to ., change one/quarter/full/half, and fractions into numbers), pasting with the unit to get outputs like "100mg." Note that this process is not foolproof and some dosages will inevitably be missed.

Similarly for units we look at pills first, and if this is unavailable we use quantity (note that quantity is only not NA if pills and all dosage cols are NA). This is converted to a numeric variable and output.

Value

dataframe with columns 'hash_str', 'title', 'prediction', 'dosage', 'unit'


xhtai/heisenbrgr documentation built on June 8, 2019, 9:30 a.m.