fapply                  package:emu                  R Documentation

_F_u_n_c_t_i_o_n _t_h_a_t _a_p_p_l_i_e_s _a _f_u_n_c_t_i_o_n _t_o _a_n _E_M_U _s_p_e_c_t_r_a_l _o_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Applies a function to an EMU spectral object.

_U_s_a_g_e:

     fapply(specdata, fun, ..., power = FALSE, powcoeffs = c(10, 10))

_A_r_g_u_m_e_n_t_s:

specdata: A matrix or trackdata object of class spectral 

     fun: A function to be applied. 

     ...: Optional arguments to fun 

   power: A single element logical vector. If T, convert specdata to
          power values i.e. apply the function to a * specdata ^b  or a
          * specdata$data ^b where a and b powcoeffs defined below.  

powcoeffs: A 2 element numeric vector for converting dB values to power
          values. Defaults to a = 10 and b = 10. See 'power'. 

_D_e_t_a_i_l_s:

     fapply performs a similar operation to apply except that it is
     specifically designed for handling EMU spectral objects.

_V_a_l_u_e:

     If the output has the same dimensions has the input, then an
     object of the same dimensionality and class is returned. Otherwise
     it may be a vector or matrix depending on the function that is
     applied. ...

_W_a_r_n_i_n_g:

     The function can be very slow if applied to a large trackdata
     object. In this case, it may be faster to use a for-loop with the
     desired function around $data

_A_u_t_h_o_r(_s):

     Jonathan Harrington

_S_e_e _A_l_s_o:

     'apply' 'by.trackdata'

_E_x_a_m_p_l_e_s:

     # mean value per spectrum, input is a spectral matrix
     m <- fapply(vowlax.dft.5, mean)
     # as above but after converting dB to powers before
     # applying the function
     m <- fapply(vowlax.dft.5, mean, power=TRUE)
     # spectral range
     r <- fapply(vowlax.dft.5, range)
     # spectral moments applied to a trackdata object
     # m is a four-dimensional trackdata object
     m <- fapply(fric.dft, moments)
     # 1st 3 DCT coefficients calculated in a spectral matrix
     # d is a 3-columned matrix
     d <- fapply(vowlax.dft.5, dct, 3)
     # dct-smooth with 10 coefficients. d2 is spectral matrix
     d2 <- fapply(vowlax.dft.5, dct, 10, TRUE)
     # dct-smooth a trackdata object with 10 coefficients
     d3 <- fapply(fric.dft[1:4,], dct, 10, TRUE)

