Learn R Programming

IRISSeismic (version 1.6.6)

basicStats: 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)

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.

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)

Author

Jonathan Callahan jonathan@mazamascience.com

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.

Examples

Run this code
if (FALSE) {
# 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)
}

Run the code above in your browser using DataLab