sizeAsNum | R Documentation |
convert size to numeric value
sizeAsNum(x, kiloSize = 1024, verbose = FALSE, ...)
x |
|
kiloSize |
|
verbose |
|
... |
additional arguments are ignored. |
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()
.
numeric
vector representing the numeric value represented
by an abbreviated size.
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()
x <- asSize(c(1, 10,2010,22000,52200), unitType="")
x
#> "1" "10" "2k" "21k" "51k"
sizeAsNum(x)
sizeAsNum(x, kiloSize=1000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.