## Most common usage using a predetermined set of group
## boundaries and group frequencies.
cj <- c(0, 25, 50, 100, 250, 500, 1000)
nj <- c(30, 31, 57, 42, 45, 10)
(x <- grouped.data(Group = cj, Frequency = nj))
class(x)
x[, 1] # group boundaries
x[, 2] # group frequencies
## Multiple frequency columns are supported
x <- sample(1:100, 9)
y <- sample(1:100, 9)
grouped.data(cj = 1:10, nj.1 = x, nj.2 = y)
## Alternative usage with grouping of individual data.
grouped.data(x) # automatic breakpoints
grouped.data(x, breaks = 7) # forced number of groups
grouped.data(x, breaks = c(0,25,75,100)) # specified groups
grouped.data(x, y, breaks = c(0,25,75,100)) # multiple data sets
## Not run: ## Providing two or more data sets and automatic breakpoints is
# ## very error-prone since the range of the first data set has to
# ## include the ranges of all the other data sets.
# range(x)
# range(y)
# grouped.data(x, y, group = TRUE)## End(Not run)
Run the code above in your browser using DataLab