numeric: Numeric functions

Description Usage Arguments Details Value Examples

Description

These functions provide Lisp/Scheme-friendly aliases for and thin wrappers around some numeric infix operators from base R.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
expt(e1, e2)

quotient(e1, e2)

remainder(e1, e2)

modulo(e1, e2)

is.number(x)

is.even(x)

is.odd(x)

is.zero(x)

is.positive(x)

is.negative(x)

Arguments

e1

For expt, quotient, remainder and modulo, the left-hand argument to the underlying infix operator.

e2

For expt, quotient, remainder and modulo, the right-hand argument to the underlying infix operator.

x

An R object on which to check a predicate.

Details

The expt, quotient, remainder and modulo functions are aliases for the following base operators:

The is.number function is an alias for the is.numeric function from base; the other is.* functions are simple predicates that do what their names suggest.

Value

For the is.* functions, TRUE or FALSE; for expt, quotient, remainder and modulo, the result of the operation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
expt(4, 5) == 4^5 #=> 1024

quotient(10, 3) == 10 %/% 3 #=> 3

remainder(10, 3) == 10 %% 3 #=> 1

modulo(10, 3) == 10 %% 3 #=> 1

is.number(3) && !is.number("foo")

is.even(22) && !is.even(23)

is.odd(23) && !is.odd(22)

is.zero(0) && !is.zero(1)

is.positive(234) && !is.positive(-34)

is.negative(-34) && !is.negative(234)

wwbrannon/schemeR documentation built on May 4, 2019, 12:03 p.m.