asSize | R Documentation |
convert numeric value to size
asSize(
x,
humanFriendly = TRUE,
digits = 3,
abbreviateUnits = TRUE,
unitType = "bytes",
unitAbbrev = gsub("^(.).*$", "\\1", unitType),
kiloSize = 1024,
sep = " ",
...
)
x |
numeric vector |
humanFriendly |
logical, currently only TRUE is accepted, whether to include human-friendly units to the output. |
digits |
integer number of digits used by |
abbreviateUnits |
logical whether to print abbreviated units, for example using k, M, G, T, P instead of kilo, mega, Giga, Tera, Peta, respectively. |
unitType |
character string indicating the base unit of measure, by default "bytes". Note that trailing "s" is removed when the number is singular. |
unitAbbrev |
character string indicating an abbreviated base unit,
by default it uses the first character from |
kiloSize |
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. |
sep |
delimiter used between the numeric value and the unit. |
... |
other parameters passed to |
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.
character
vector representing human-friendly sizes.
Other jam string functions:
breaksByVector()
,
cPasteSU()
,
cPasteS()
,
cPasteUnique()
,
cPasteU()
,
cPaste()
,
fillBlanks()
,
formatInt()
,
gsubOrdered()
,
gsubs()
,
makeNames()
,
mixedOrder()
,
mixedSortDF()
,
mixedSorts()
,
mixedSort()
,
mmixedOrder()
,
nameVectorN()
,
nameVector()
,
padInteger()
,
padString()
,
pasteByRowOrdered()
,
pasteByRow()
,
sizeAsNum()
,
tcount()
,
ucfirst()
,
uniques()
asSize(c(1, 10,2010,22000,52200))
#> "1 byte" "10 bytes" "2 kb" "21 kb" "51 kb"
# demonstration of straight numeric units
asSize(c(1, 100, 1000, 10000), unitType="", kiloSize=100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.