numerate {comprehenr} | R Documentation |
Auxiliary functions for working with lists
Description
-
numerate
returns list of lists. Each list consists of two elements: sequential number of element and element. Reverse operation -unumerate
. -
mark
returns list of lists. Each list consists of two elements: name of element and element. Reverse operation -unmark
. -
zip_lists
combines lists side-by-sidy. Reverse operation -unzip_list
. -
unzip_list
is similair to matrix transposition but for list of lists. -
lag_list
converts argument to list of arguments with previous values:x
->list(x[i-1], x[i])
.
Usage
numerate(x)
enumerate(x)
unnumerate(x, item = 2)
mark(x)
unmark(x, item = 2)
unzip_list(x)
zip_lists(...)
lag_list(x)
Arguments
x |
list, vector or list of lists |
item |
numeric number of list in which stored values |
... |
lists which will be zipped |
Value
list or list of lists
Examples
cities = c('Chicago', 'Detroit', 'Atlanta')
airports = c('ORD', 'DTW', 'ATL')
pairs = zip_lists(cities, airports)
str(pairs)
str(unzip_list(pairs))
str(numerate(cities))
named_list = c('Chicago' = 'ORD', 'Detroit' = 'DTW', 'Atlanta' = 'ATL')
str(mark(named_list))
set.seed(123)
rand_sequence = runif(20)
# gives only locally increasing values
to_vec(for(`i, j` in lag_list(rand_sequence)) if(j>i) j)
[Package comprehenr version 0.6.10 Index]