conv_len: Convert lengths

Description Usage Arguments Details Examples

Description

Convert lengths from character vector, containing values like "3/4" and "hd" into a numeric vector.

Usage

1

Arguments

lengths

character vector of lengths

Details

This function makes some assumptions, so may need tweaking over time. For each string in a vector it is first split up by the spaces in it, so "1 3/4" is split into "1" "3/4", if there are no spaces then it assesses the single number/letters against a list of common length margins. If the split vector has length 2 then it assumes the first element is a whole number, and the second is a fraction (like "3/4"), it calculates the total margin. There is no doubt for edge cases that this function doesn't cover which will cause errors, the function was harder to write than initially thought, and will likely need improvements as edge cases are encountered

Examples

1
2
3
4
5
## Not run: 
lengths <- c("0", "nse", "hd", "3/4", "1 1/2")
conv_len(lengths = lengths)

## End(Not run)

durtal/RcappeR documentation built on May 15, 2019, 6 p.m.