adjustUnitPrefix: Adjust Value With Different Decimal Prefixes To Single Prefix...

View source: R/adjustUnitPrefix.R

adjustUnitPrefixR Documentation

Adjust Value With Different Decimal Prefixes To Single Prefix Plus Unit

Description

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.

Usage

adjustUnitPrefix(
  x,
  pref = c("z", "a", "f", "p", "n", "u", "m"),
  unit = "sec",
  sep = c(".", " ", ""),
  headingTxt = "",
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

x

(character) vector containing digit uunit-prefix and unit terms

pref

(character) multiplicative unit-prefixes, assumes as increasing factors of 1000

unit

(character) unit name, the numeric part may be sepatated by one space-character

sep

(character) separator characters that may appear between integer numeric value and unit description

headingTxt

(character) additional text preceeding the numeric part of 'x' to be ingnored/removed

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Details

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 NAs will be returned.

Please note the 'u' is used for 'micro'.

Value

This function returns a numeric vector with quantities extracted and adjusted to a single type of unit (without the unit description)

See Also

convToNum

Examples

adjustUnitPrefix(c("10.psec abc","2 fsec etc"), unit="sec")

wrMisc documentation built on Nov. 17, 2023, 5:09 p.m.