mul {Rsac}R Documentation

Some simple arithmetic

Description

These are provided as a matter of convience since any R functions can be easily applied to the vectors of SAC data (see below for examples). These functions apply basic arithmetic functions to each SAC data in a vector. The constant may be the same or different for each SAC file. If less constants are given than files in the vector, then the last constant provided is used for the remainder of the files, to be consistent with the behavior of the original SAC code.

Usage

mul(s, c)
add(s, c)
pow(s, c)

Arguments

s an object of class "rsac".
c a constant to be applied to the data.

Value

same as input.

Author(s)

Eric M. Thompson <eric.thompson@tufts.edu>

Examples


data(srosa)

getunits(srosa)
# Convert to m/s
srosa <- mul(srosa, 1e-9)
plot(srosa, xlim = c(150, 160))

# this is also easy to do using the
# lapply() function
class(srosa)
mode(srosa)

# for all files

m <- function(X){
       X$x <- X$x * 1e-9
       return(X) }
srosa <- lapply(X = srosa, m)

# Or individually:

srosa[[1]]$x <- abs(srosa[[1]]$x)


[Package Rsac version 0.1-7 Index]