convert size to numeric value
sizeAsNum(x, kiloSize = 1024, verbose = FALSE, ...)
character
vector. When x
is numeric, it is returned as-is;
otherwise x is coerced to character
with as.character()
and
will throw an error if it fails.
numeric
number of base units when converting from one
base unit, to one "kilo" base unit. For file sizes, this value is 1024,
but for other purposes this value may be 1000, like one thousand units
is "1k units"
.
logical
indicating whether to print verbose output.
The output includes a data.frame
summarizing the input,
and the unit matched, and the final value. If verbose==2
it
will return this data.frame
for review.
additional arguments are ignored.
numeric
vector representing the numeric value represented
by an abbreviated size.
This function is intended to provide the inverse of asSize()
by converting an abbreviated size into a full numeric value.
It makes one simplifying assumption, that the first character in
the unit is enough to determine the unit. This assumption also means
the units are currently case-sensitive, for example Mega
requires
upper-case "M"
, because "milli"
which is not supported,
requires "m"
.
Unit abbreviations recognized:
k
- kilo - size is defined by kiloSize
M
- Mega - size is defined by kiloSize ^ 2
G
- Giga - size is defined by kiloSize ^ 3
T
- Tera - size is defined by kiloSize ^ 4
P
- Peta - size is defined by kiloSize ^ 5
Everything else is considered to have no abbreviated units, thus the numeric value is returned as-is.
Note that the round trip asSize()
followed by sizeAsNum()
will
not produce identical values, because the intermediate value is
rounded by digits
in asSize()
.
Other jam string functions:
asSize()
,
breaksByVector()
,
cPasteSU()
,
cPasteS()
,
cPasteUnique()
,
cPasteU()
,
cPaste()
,
fillBlanks()
,
formatInt()
,
gsubOrdered()
,
gsubs()
,
makeNames()
,
mixedOrder()
,
mixedSortDF()
,
mixedSorts()
,
mixedSort()
,
mmixedOrder()
,
nameVectorN()
,
nameVector()
,
padInteger()
,
padString()
,
pasteByRowOrdered()
,
pasteByRow()
,
tcount()
,
ucfirst()
,
uniques()