list.skipWhile: Keep skipping elements while a condition holds

Description Usage Arguments See Also Examples

View source: R/list.skip.R

Description

Keep skipping elements in a list or vector while a condition holds for the element. As long as the condition is violated, the element will be kept and all remaining elements are returned.

Usage

1
list.skipWhile(.data, cond)

Arguments

.data

A list or vector

cond

A logical lambda expression

See Also

list.skip, list.take, list.takeWhile

Examples

1
2
3
4
5
x <- list(p1 = list(type='A',score=list(c1=10,c2=8)),
       p2 = list(type='B',score=list(c1=9,c2=9)),
       p3 = list(type='B',score=list(c1=9,c2=7)))
list.skipWhile(x, type=='A')
list.skipWhile(x, min(score$c1,score$c2) >= 8)

Example output

$p2
$p2$type
[1] "B"

$p2$score
$p2$score$c1
[1] 9

$p2$score$c2
[1] 9



$p3
$p3$type
[1] "B"

$p3$score
$p3$score$c1
[1] 9

$p3$score$c2
[1] 7



$p3
$p3$type
[1] "B"

$p3$score
$p3$score$c1
[1] 9

$p3$score$c2
[1] 7

rlist documentation built on Sept. 5, 2021, 5:30 p.m.