Description Usage Arguments Details Examples
Quantity operations
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
... |
a number of quantities (or numerics depending on the operation) |
na.rm |
logical. Should missing values be removed? |
unit |
a character string or vector with a unit specification |
x, y |
a quantity or a numeric |
ql |
a list of quantities and, eventually, NULLs |
skipNull |
logical Skip NULL elements in unlist |
sameQdim test whether or not two quantities have the same dimension. There scale may differ.
the Q equivalent for unlist. All non-NULL elements must have the same dimension and all scales are converted to the scale of the first element.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | x <- as.quantity (2, 'time$day')
y <- as.quantity (12, 'time$hour')
qSum (x,y) # returns 2,5 days
qSum (y,x) # returns 60 hours
qSum (x,y, unit='time$week')
x <- as.quantity (c(1,2,3), 'time$day')
qMax (x,y) # returns 3 days
x <- as.quantity (c(1,2,3), 'time$day')
qMin (x,y) # returns 1 day
x <- as.quantity (2, 'time$second')
qInv (x) # returns 0.5 second⁻¹
x <- as.quantity (2, 'time$day')
y <- as.quantity (12, 'time$hour')
qProd (x, y) # returns 1 day²
qProd (y, x) # returns 576 hours²
x <- as.quantity (2, 'time$day')
y <- as.quantity (12, 'time$hour')
qDiv (x,y) # returns 4
qDiv (y,x) # returns .25
x <- as.quantity (2, 'time$day')
y <- as.quantity (12, 'time$hour')
sameQdim (x,y) # returns TRUE
x <- as.quantity (2, 'time$day')
y <- as.quantity (12, 'time$hour')
qUnlist (list (x, NULL, y)) # returns as.quantity (c(2, .5), time$day)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.