Description Usage Arguments Value Examples
rank a numeric vector and returns a new ordinal vector
1 | rank2group(y, k = 4)
|
y |
a numeric vector |
k |
a integer specifies how many groups you want to classify. default value is 4 |
a ordinal vector(numeric) with the same length of y
1 2 3 4 5 6 7 8 9 10 11 12 | require(ggplot2)
data(diamonds)
diamonds$PriceGroup=rank2group(diamonds$price,4)
table(diamonds$PriceGroup)
aggregate(price~PriceGroup,data=diamonds,range)
diamonds$PriceGroup3=rank2group(diamonds$price,3)
table(diamonds$PriceGroup3)
aggregate(price~PriceGroup3,data=diamonds,range)
diamonds$PriceGroup5=rank2group(diamonds$price,5)
table(diamonds$PriceGroup5)
aggregate(price~PriceGroup5,data=diamonds,range)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.