eem_apply {staRdom} | R Documentation |
Applying functions on EEMs
Description
Applying functions on EEMs
Usage
eem_apply(data, func, return = c("eemlist", "value"), ...)
Arguments
data |
eemlist to be modified |
func |
a function to be applied on the data. |
return |
either "eemlist" or "value" |
... |
additional arguments passed on to func |
Details
The EEMs are passed on as first argument to func. Additionally, the vector of excitation wavelengths is passed on as ex
and the emission wavelengths as em
. Therefore, the supplied function has to allow these arguments. The easiest way would be ...
(see example).
Value
eemlist or list
Examples
## define a function, that would divide a matrix by its maximum
# more general, if you want to return a valid eemlist (see below),
# a matrix of the same size has to be returned
# ... is used as a placeholder for any argument, important: em and
# ex wavelengths are passed on, so the function needs to take them as arguments,
# even if they are not used
norm_max <- function(x, ...){
x/max(x)
}
# load example data
data("eem_list")
# normalise eems by the function defined above
norm_eems <- eem_apply(eem_list,norm_max,"eemlist")
# plot the results to see the difference
ggeem(norm_eems)
# define another function. what values were used to
# multiply the eems with?
norm_fac <- function(x, ...){
1/max(x)
}
# return a list of factors used for normalisation
norm_factors <- eem_apply(eem_list,norm_fac,"value")
unlist(norm_factors)
# return list of em vectors.
# important: x needs to be in the first position, but
# is not used later!
extr_em <- function(x,em,...){
em
}
em_vectors <- eem_apply(eem_list,extr_em,"value")
em_vectors
[Package staRdom version 1.1.28 Index]