basicStats: Length, Max, Mean, Median, Min and Standard Deviation

basicStatsR Documentation

Length, Max, Mean, Median, Min and Standard Deviation

Description

Basic statistics on the data in Trace and Stream objects.

Usage

# length(x)
# max(x, ...)
mean(x, ...)
# median(x, na.rm)
# min(x, ...)
sd(x, na.rm)
parallelLength(x)
parallelMax(x, na.rm)
parallelMean(x, na.rm)
parallelMedian(x, na.rm)
parallelMin(x, na.rm)
parallelSd(x, na.rm)

Arguments

x

a Trace or Stream object

na.rm

a logical specifying whether missing values should be removed

...

arguments to be passed to underlying methods, e.g. the mean function:

  • na.rm – as above (default=FALSE)

Details

Trace methods

When x is a Trace object, methods length, max, mean, median, min and sd operate on the data slot of the Trace and are equivalent to, e.g., max(x@data, na.rm=FALSE).

Stream methods

When x is a Stream object, methods length, max, mean, median, min and sd are applied to the concatenation of data from every Trace in the Stream, treating this as a single data series.

The parallel~ versions of these methods are available only on Stream objects and return a vector of values, one for each Trace.

By default, the Stream-method versions of these methods use na.rm=FALSE as there should be no missing datapoints in each Trace. The Trace methods default to na.rm=TRUE to accommodate merged traces where gaps have been filled with NAs.

Value

For the simple statistics, a single numeric value is returned or NA if the Trace or Stream has no data.

For the parallel~ versions of these methods, available on Stream objects, a numeric vector is returned of the same length as Stream@traces.

Note

See the R documentation on the respective base functions for further details.

The length.Stream method only counts the number of actual data values in the individual Traces in the Stream object. Missing values associated with the gaps between Traces are not counted.

Author(s)

Jonathan Callahan jonathan@mazamascience.com

Examples

## Not run: 
# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")

starttime <- as.POSIXct("2012-01-24", tz="GMT")
endtime <- as.POSIXct("2012-01-25", tz="GMT")

# Get the waveform
st <- getDataselect(iris,"AK","PIN","","BHZ",starttime,endtime)

# Get the first trace and generate some statistics
tr1 <- st@traces[[1]]
length(tr1)
max(tr1)
mean(tr1)
sd(tr1)

## End(Not run)

IRISSeismic documentation built on Oct. 16, 2022, 1:09 a.m.