isAsQuantity: Create, convert or test objects with class 'quantity'

Description Usage Arguments Details Value Examples

Description

Create, convert or test objects with class 'quantity'

Usage

 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
is.quantity(x)

as.quantity(x, unit)

qUnits(qName)

qUnit(x)

qDim(x)

qSymbol(x)

qText(x)

is.mass(x)

as.mass(x, unit = "kilo.gram")

is.force(x)

as.force(x, unit = "newton")

is.energy(x)

as.energy(x, unit = "joule")

is.power(x)

as.power(x, unit = "watt")

is.length(x)

as.length(x, unit = "metre^3")

is.area(x)

as.area(x, unit = "metre^2")

is.volume(x)

as.length(x, unit = "metre^3")

is.time(x)

as.time(x, unit = "second")

is.frequency(x)

as.frequency(x, unit = "second^-1")

is.angle(x)

as.angle(x, unit = "angle")

Arguments

x

an quantity or a numeric object

unit

a character string or character vector specifying the units of measurement

qName

a charater string with the name of a quantity, e.g. 'time'

Details

the unit is specified as a character string with single unit specifications seperated by spaces. The first single unit specification may specify a metric quantity prefix, the other specify a single unit by the quantity name, a '$', an optional metric unit prefix followed by a'.', an optional unit name, and an optional exponent preceeded by a '^'. If the prefix is ommitted the default will be 'none', if the unit name is ommited the default will be the one as specified in the quantity definition, and if the exponent is ommitted the default will be 1.
as.qqq (x, 'uuu') is just a short-hand for as.quantity (x, 'qqq$uuu)
If x is a numeric it is coverted to quntity wiht the same value and unit as uuu. If x is a qunatity its value is converted to uuu.

Value

is.quantity returns TRUE or FALSE depending on wether or not x is of a class 'quantity'
as.quantity converts a numeric to a 'quantity' or converts the scale of a quantity
is.qqq returns TRUE or FALSE depending on wether or not x is an qqq quantity
as.qqq returns a qqq quantity
qUnit returns a character string with the unit specification
qSymbol returns a character string with the quantity symbol(s)
qText returns a character string with the quantity as textdev

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
is.quantity (1)                              # returns  FALSE
is.quantity (as.quantity (1, unit='mass'))   # returns TRUE
as.quantity (5, 'time$milli.second^-2')  # returns 5 millisecond⁻²
t <- as.quantity (60, 'time')
t                                    # returns 60 seconds
as.quantity (t, 'time$minute')       # returns 1 minute
qUnits ('time') [6:9]                # returns "day" "hour" "minute" "second"
qUnit (1)                            # raises an error
t <- as.quantity (1, 'time')
qUnit (t)                            # returns "time$second"
qUnit (1)                            # raises an error
t <- as.quantity (1, 'time')
qUnit (t)
t <- as.quantity (2, unit='time$second')
qSymbol (t)                          # returns 's'
t <- as.quantity (2, unit='time$second')
qText (t)                            # returns 'seconds'

Pisca46/quantities documentation built on May 31, 2019, 11:41 p.m.