Divvy: Divvy Function

Description Usage Arguments Details Value Author(s) Examples

Description

This function splits the integers from 1 to n into g groups and returns the ith group. All of this is straightforward, but it's important to do it in a consistent way for splitting up data/analyses.

Usage

1
2
3
Divvy(first.idx, last.idx, which.group,
  num.groups = ceiling(n.idxs/group.size),
  group.size = ceiling(n.idxs/num.groups))

Arguments

num.groups

number of groups to divvy the items into, defaults to ceiling(n/group.size)

group.size

size of each group, defaults to ceiling(n/num.groups)

n

number of items to divvy up

i

group of items to return

Details

The gth group may be smaller than the other groups

Value

the indices of the ith group of size g in 1:n

Author(s)

Robert Corty

Examples

1
2
3
Divvy(first.idx = 10, last.idx = 50, num.groups = 3, which.group = 1)
Divvy(first.idx = 10, last.idx = 50, num.groups = 3, which.group = 2)
Divvy(first.idx = 10, last.idx = 50, num.groups = 3, which.group = 3)

rcorty/CortyKit documentation built on May 27, 2019, 3:03 a.m.