expand.int: Function to expand integers to a grid of indices

Description Usage Arguments Value Examples

View source: R/funDataMethods.R

Description

This function takes an arbitrary number K of integer values n_1,…, n_K and creates a data frame with all combinations from 1:n_k, where the first column (taking values from 1 to n_1) varies slowest and the last column (())taking values from 1 to n_K) varies fastest. Internally, this function depends on expand.grid

Usage

1

Arguments

...

An arbitrary number of integer values.

Value

A dataframe with the same number of columns as integers supplied and containing all combinations of indices from 1 to the given integers. If no number is supplied, the function returns NULL.

Examples

1
2
3
4
5
# For two integers
funData:::expand.int(2,5) # first column varies slowest

# For three integers
funData:::expand.int(2,3,4)

Example output

Attaching package: 'funData'

The following object is masked from 'package:stats':

    integrate

   Var1 Var2
1     1    1
2     1    2
3     1    3
4     1    4
5     1    5
6     2    1
7     2    2
8     2    3
9     2    4
10    2    5
   Var1 Var2 Var3
1     1    1    1
2     1    1    2
3     1    1    3
4     1    1    4
5     1    2    1
6     1    2    2
7     1    2    3
8     1    2    4
9     1    3    1
10    1    3    2
11    1    3    3
12    1    3    4
13    2    1    1
14    2    1    2
15    2    1    3
16    2    1    4
17    2    2    1
18    2    2    2
19    2    2    3
20    2    2    4
21    2    3    1
22    2    3    2
23    2    3    3
24    2    3    4

funData documentation built on Oct. 17, 2021, 5:06 p.m.