numerate

0th

Percentile

Auxiliary functions for working with lists

  • 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 combine lists side-by-sidy. Reverse operation - unzip_list.

  • unzip_list It's similair to matrix transposition but for list of lists.

  • lag_list convert 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

Aliases
  • numerate
  • enumerate
  • unnumerate
  • mark
  • unmark
  • unzip_list
  • zip_lists
  • lag_list
Examples
# NOT RUN {
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)
# }
Documentation reproduced from package comprehenr, version 0.6.7, License: GPL-2

Community examples

Looks like there are no examples yet.