time_reso: Sampling rate of a TDR dataset

Description Usage Arguments Details Author(s) See Also Examples

Description

Sampling rate of a TDR dataset

Usage

1
time_reso(x, type = c("period", "frequence"))

Arguments

x

The time sequence.

type

Should the result be returned in seconds ("period") or hertz ("frequence") ?

Details

Sampling interval taken as the greatest common divisor of observed intervals.

Author(s)

Yves Le Bras, Simon Wotherspoon

See Also

all.equal

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
time_reso(seq(0, 10, by = 1/0.5), type = "freq")
time_reso(seq(0, 10, by = 1),     type = "freq")
time_reso(seq(0, 10, by = 1/2),   type = "freq")
time_reso(seq(0, 10, by = 1/5),   type = "freq")
time_reso(seq(0, 10, by = 1/16),  type = "freq")

# Please notice that exact equality may not be always true 
# due to realities of computer arithmetic
## Not run: 
# Assuming a sufficient number of decimales...
repeat {
  f <- runif(1, 0, 100)
  tst <- seq(0, 10, by = 1/f)
  if (length(tst) > 1) break
}
time_reso(tst, type = "f") == f          # is TRUE in most cases
all.equal(time_reso(tst, type = "f"), f) # is TRUE

## End(Not run)

SESman/rbl documentation built on May 9, 2019, 11:10 a.m.