This function provides help converting values with with different unit-prefixes to a single prefix-unit type. This can be used to convert a vector of mixed prefixes like 'p' and 'n'. Any text to the right of the unit will be ignored.
adjustUnitPrefix(
x,
pref = c("z", "a", "f", "p", "n", "u", "m"),
unit = "sec",
sep = c(".", " ", ""),
headingTxt = "",
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
This function returns a numeric vector with quantities extracted and adjusted to a single type of unit (without the unit description)
(character) vector containing digit uunit-prefix and unit terms
(character) multiplicative unit-prefixes, assumes as increasing factors of 1000
(character) unit name, the numeric part may be sepatated by one space-character
(character) separator characters that may appear between integer numeric value and unit description
(character) additional text preceeding the numeric part of 'x' to be ingnored/removed
(logical) suppress messages
(logical) additional messages for debugging
(character) allow easier tracking of messages produced
Please note that the current version recognizes and converts only interger values, decimals or scientific writing won't work.
The resultant numeric vector expresses all values as lowest prefix unit level.
In case of invalid entries NA
s will be returned.
Please note the 'u' is used for 'micro'.
convToNum
adjustUnitPrefix(c("10.psec abc","2 fsec etc"), unit="sec")
Run the code above in your browser using DataLab