Learn R Programming

geoSpectral (version 0.17.5)

spc.lapply: Apply a function over a Spclist

Description

lapply returns a list of the same length as X, each element of which is the result of applying FUN to the corresponding element of X.

Usage

spc.lapply(X, FUN, ...)

# S4 method for SpcList spc.lapply(X, FUN, ...)

Arguments

X

A SpcList object .

FUN

function to be applied to each element of X.

...

optional arguments to FUN.

Value

list or SpcList object.

Examples

Run this code
# NOT RUN {
 
sp=spc.example_spectra()
BL=spc.makeSpcList(sp,"CAST")
#Counts rows (returns a list object)
spc.lapply(BL,function(x) {nrow(x)})
#Perform arithmetic operations on all Spectra elements. Returns a SpcList object.
spc.lapply(BL,function(x) {x^2+1})

# }

Run the code above in your browser using DataLab