Description Usage Arguments Value Note Author(s) See Also Examples
Creates groups where the groups each have as close to the same number of members as possible.
1 2 |
x |
a numeric vector. |
ngroups |
a positive integer giving the number of groups to create. |
na.rm |
logical value: if |
result |
a character string specifying the form of the resulting value.
This must be (an abbreviation of) one of: |
reverse |
logical value: if |
checkBleed |
logical value: if |
the form of the value depends on the result
argument.
The "list"
result has the values of the input x
grouped
into ngroups
components.
The "numeric"
result is a vector of integers from 1
to ngroups
indicating which group the corresponding element
of x
is in.
The "factor"
result is an ordered factor version of the
"numeric"
result.
A more primitive version of this function appeared in a blog post called "Miles of iles" on the Portfolio Probe website. A bit of comparison with the alternative functions in See Also may be found there.
Pat Burns
1 2 3 4 5 |
$`1`
Connecticut Delaware Hawaii New Jersey Rhode Island
5009 2057 6450 7836 1214
$`2`
Maryland Massachusetts New Hampshire Vermont West Virginia
10577 8257 9304 9609 24181
$`3`
Indiana Kentucky Maine South Carolina Virginia
36291 40395 33215 31055 40815
$`4`
Louisiana Mississippi Ohio Pennsylvania Tennessee
48523 47716 41222 45333 42244
$`5`
Alabama Arkansas New York North Carolina Wisconsin
51609 53104 49576 52586 56154
$`6`
Florida Georgia Illinois Iowa Michigan
58560 58876 56400 56290 58216
$`7`
Missouri North Dakota Oklahoma South Dakota Washington
69686 70665 69919 77047 68192
$`8`
Idaho Kansas Minnesota Nebraska Utah
83557 82264 84068 77227 84916
$`9`
Arizona Colorado Nevada Oregon Wyoming
113909 104247 110540 96981 97914
$`10`
Alaska California Montana New Mexico Texas
589757 158693 147138 121666 267339
[1] 5 4 3 2 2 1 5 4 3 2 1 1 5 4 3 2 1 1 5 4 4 3 2 1 5 4 3 2 1 1 5 4 4 3 2 1 5 4
[39] 3 3 2 1 5 4 3 2 2 1 5 5 4 3 2 1 5 4 3 2 2 1 5 4 3 3 2 1 5 4 3 3 2 1 5 4 4 3
[77] 2 1 5 5 4 3 2 1
Levels: 5 < 4 < 3 < 2 < 1
$`1`
[1] -10 -9 -8 -7 -6 -5 -4
$`2`
[1] -3 -2 -1 0 0 0 0
$`3`
[1] 1 2 3 0 0 0 0
$`4`
[1] 4 5 6 7 8 9 10
Warning message:
In ntile(c(-10:10, rep(0, 7)), 4) : common values across groups: 2, 3
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.