Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

modulo_floor

Nearest value below


Description

Returns the nearest m-length value (downwards from n).

Usage

modulo_floor(n, m = 2L)

Arguments

n

integer; the number of terms (can be a vector)

m

integer; the modulo term (cannot be zero)

Details

This function is different from nextn in that the value is floored. For example: 10 is the result for n=11,m=2 whereas nextn would give 12.

Author(s)

A.J. Barbour

See Also

psd-utilities; psdcore uses this to truncate series to their nearest even length (i.e., m=2).

Examples

n <- 11
nextn(n) # 12
modulo_floor(n) # 10

# works on vectors too:
# defaults to m=2
modulo_floor(seq_len(n))
#[1]  0  2  2  4  4  6  6  8  8 10 10

# change the floor factor
modulo_floor(seq_len(n), 3)
#[1] 0 0 3 3 3 6 6 6 9 9 9

# zeros are not allowed for m
try(modulo_floor(n, 0))

psd

Adaptive, Sine-Multitaper Power Spectral Density and Cross Spectrum Estimation

v2.1.0
GPL (>= 2)
Authors
Andrew J. Barbour [aut, cre] (<https://orcid.org/0000-0002-6890-2452>), Jonathan Kennel [aut] (<https://orcid.org/0000-0003-4474-6886>), Robert L. Parker [aut]
Initial release
2020-06-28

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.