lc: Perform Python-like list comprehensions in R

Description Usage Arguments Value Examples

Description

Evaulates expr for each value passed in keyword args, as in foreach

Usage

1
lc(expr, ..., condition, .combine = c)

Arguments

expr

The expression to evaluate

...

The keyword arguments to be passed to foreach

condition

An optional condition to evaluate before returning a result for each item

.combine

A combine function to be passed to foreach

Value

A vector of out values.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cormatrix <- structure(list(As = c(NA, 0.597861790755909, NA, NA, NA, NA, 
1, NA, NA, NA), Pb = c(NA, NA, 0.756832335863065, NA, NA, NA, 
NA, NA, NA, NA), Zn = c(NA, 0.581426445499464, NA, NA, 0.562975973699551, 
NA, 0.589760572528395, NA, NA, NA), V = c(NA, NA, NA, NA, -0.558938721862234, 
NA, NA, NA, 0.796385319562529, NA), Cr = c(NA, NA, 0.815492040792347, 
NA, NA, NA, NA, NA, NA, NA)), .Names = c("As", "Pb", "Zn", "V", 
"Cr"), row.names = c("S", "Cl", "Ti", "Mn", "Fe", "Co", "As", 
"Mo", "Ag", "Sn"), class = "data.frame")

lc(!all(is.na(cormatrix[i,])), i=1:nrow(cormatrix))

paleolimbot/rfuncs documentation built on May 24, 2019, 6:13 p.m.