View source: R/8_function_operators.R
recursive_filter | R Documentation |
Standard function operator.
recursive_filter(f, x)
first(f, x)
last(f, x)
nth(f, x, n)
f |
A function that returns TRUE or FALSE. |
x |
A vector to be filtered. |
n |
The nth element desired. 1 means first. |
Filter any function.
library(functionalPlayground)
recursive_filter(is_even, 1:10)
recursive_filter(is_odd, 1:10)
first(is_even, 1:10)
first(is_odd, 1:10)
last(is_even, 1:10)
last(is_odd, 1:10)
nth(is_even, 1:10, 1) # same as first(is_even, 1:10)
nth(is_even, 1:10, 2) # second even element
nth(is_odd, 1:10, 3) # third odd element
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.