Skip to content

Commit b01f0e0

Browse files
ws & line width in Rd (#7117)
1 parent cf7fb11 commit b01f0e0

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

man/groupingsets.Rd

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,30 @@ rollup(x, \dots)
1515
cube(x, \dots)
1616
\method{cube}{data.table}(x, j, by, .SDcols, id = FALSE, label = NULL, \dots)
1717
groupingsets(x, \dots)
18-
\method{groupingsets}{data.table}(x, j, by, sets, .SDcols, id = FALSE, jj, label = NULL, enclos = parent.frame(), \dots)
18+
\method{groupingsets}{data.table}(x, j, by, sets, .SDcols,
19+
id = FALSE, jj, label = NULL, enclos = parent.frame(), \dots)
1920
}
2021
\arguments{
21-
\item{x}{\code{data.table}.}
22-
\item{\dots}{argument passed to custom user methods. Ignored for \code{data.table} methods.}
23-
\item{j}{expression passed to data.table \code{j}.}
24-
\item{by}{character column names by which we are grouping.}
25-
\item{sets}{list of character vector reflecting grouping sets, used in \code{groupingsets} for flexibility.}
26-
\item{.SDcols}{columns to be used in \code{j} expression in \code{.SD} object.}
27-
\item{id}{logical default \code{FALSE}. If \code{TRUE} it will add leading column with bit mask of grouping sets.}
28-
\item{jj}{quoted version of \code{j} argument, for convenience. When provided function will ignore \code{j} argument.}
29-
\item{label}{label(s) to be used in the 'total' rows in the grouping variable columns of the output, that is, in rows where the grouping variable has been aggregated. Can be a named list of scalars, or a scalar, or \code{NULL}. Defaults to \code{NULL}, which results in the grouping variables having \code{NA} in their 'total' rows. See Details.}
30-
\item{enclos}{the environment containing the symbols referenced by \code{jj}. When writing functions that accept a \code{j} environment for non-standard evaluation by \pkg{data.table}, \code{\link[base]{substitute}()} it and forward it to \code{groupingsets} using the \code{jj} argument, set this to the \code{\link[base]{parent.frame}()} of the function that captures \code{j}.}
22+
\item{x}{\code{data.table}.}
23+
\item{\dots}{argument passed to custom user methods. Ignored for \code{data.table} methods.}
24+
\item{j}{expression passed to data.table \code{j}.}
25+
\item{by}{character column names by which we are grouping.}
26+
\item{sets}{list of character vector reflecting grouping sets, used in \code{groupingsets} for flexibility.}
27+
\item{.SDcols}{columns to be used in \code{j} expression in \code{.SD} object.}
28+
\item{id}{logical default \code{FALSE}. If \code{TRUE} it will add leading column with bit mask of grouping sets.}
29+
\item{jj}{quoted version of \code{j} argument, for convenience. When provided function will ignore \code{j} argument.}
30+
\item{label}{label(s) to be used in the 'total' rows in the grouping variable columns of the output, that is, in rows where the grouping variable has been aggregated. Can be a named list of scalars, or a scalar, or \code{NULL}. Defaults to \code{NULL}, which results in the grouping variables having \code{NA} in their 'total' rows. See Details.}
31+
\item{enclos}{the environment containing the symbols referenced by \code{jj}. When writing functions that accept a \code{j} environment for non-standard evaluation by \pkg{data.table}, \code{\link[base]{substitute}()} it and forward it to \code{groupingsets} using the \code{jj} argument, set this to the \code{\link[base]{parent.frame}()} of the function that captures \code{j}.}
3132
}
3233
\details{
33-
All three functions \code{rollup, cube, groupingsets} are generic methods, \code{data.table} methods are provided.
34+
All three functions \code{rollup, cube, groupingsets} are generic methods, \code{data.table} methods are provided.
3435

35-
The \code{label} argument can be a named list of scalars, or a scalar, or \code{NULL}. When \code{label} is a list, each element name must be (1) a variable name in \code{by}, or (2) the first element of the class in the data.table \code{x} of a variable in \code{by}, or (3) one of 'character', 'integer', 'numeric', 'factor', 'Date', 'IDate'. The order of the list elements is not important. A label specified by variable name will apply only to that variable, while a label specified by first element of a class will apply to all variables in \code{by} for which the first element of the class of the variable in \code{x} matches the \code{label} element name, except for variables that have a label specified by variable name (that is, specification by variable name takes precedence over specification by class). For \code{label} elements with name in \code{by}, the class of the label value must be the same as the class of the variable in \code{x}. For \code{label} elements with name not in \code{by}, the first element of the class of the label value must be the same as the \code{label} element name. For example, \code{label = list(integer = 999, IDate = as.Date("3000-01-01"))} would produce an error because \code{class(999)[1]} is not \code{"integer"} and \code{class(as.Date("3000-01-01"))[1]} is not \code{"IDate"}. A corrected specification would be \code{label = list(integer = 999L, IDate = as.IDate("3000-01-01"))}.
36+
The \code{label} argument can be a named list of scalars, or a scalar, or \code{NULL}. When \code{label} is a list, each element name must be (1) a variable name in \code{by}, or (2) the first element of the class in the data.table \code{x} of a variable in \code{by}, or (3) one of 'character', 'integer', 'numeric', 'factor', 'Date', 'IDate'. The order of the list elements is not important. A label specified by variable name will apply only to that variable, while a label specified by first element of a class will apply to all variables in \code{by} for which the first element of the class of the variable in \code{x} matches the \code{label} element name, except for variables that have a label specified by variable name (that is, specification by variable name takes precedence over specification by class). For \code{label} elements with name in \code{by}, the class of the label value must be the same as the class of the variable in \code{x}. For \code{label} elements with name not in \code{by}, the first element of the class of the label value must be the same as the \code{label} element name. For example, \code{label = list(integer = 999, IDate = as.Date("3000-01-01"))} would produce an error because \code{class(999)[1]} is not \code{"integer"} and \code{class(as.Date("3000-01-01"))[1]} is not \code{"IDate"}. A corrected specification would be \code{label = list(integer = 999L, IDate = as.IDate("3000-01-01"))}.
3637

37-
The \code{label = <scalar>} option provides a shorter alternative in the case where only one class of grouping variable requires a label. For example, \code{label = list(character = "Total")} can be shortened to \code{label = "Total"}. When this option is used, the label will be applied to all variables in \code{by} for which the first element of the class of the variable in \code{x} matches the first element of the class of the scalar.
38+
The \code{label = <scalar>} option provides a shorter alternative in the case where only one class of grouping variable requires a label. For example, \code{label = list(character = "Total")} can be shortened to \code{label = "Total"}. When this option is used, the label will be applied to all variables in \code{by} for which the first element of the class of the variable in \code{x} matches the first element of the class of the scalar.
3839
}
3940
\value{
40-
A data.table with various aggregates.
41+
A data.table with various aggregates.
4142
}
4243
\seealso{ \code{\link{data.table}}, \code{\link{rbindlist}}
4344
}
@@ -49,11 +50,11 @@ groupingsets(x, \dots)
4950
n = 24L
5051
set.seed(25)
5152
DT <- data.table(
52-
color = sample(c("green","yellow","red"), n, TRUE),
53-
year = as.Date(sample(paste0(2011:2015,"-01-01"), n, TRUE)),
54-
status = as.factor(sample(c("removed","active","inactive","archived"), n, TRUE)),
55-
amount = sample(1:5, n, TRUE),
56-
value = sample(c(3, 3.5, 2.5, 2), n, TRUE)
53+
color = sample(c("green","yellow","red"), n, TRUE),
54+
year = as.Date(sample(paste0(2011:2015,"-01-01"), n, TRUE)),
55+
status = as.factor(sample(c("removed","active","inactive","archived"), n, TRUE)),
56+
amount = sample(1:5, n, TRUE),
57+
value = sample(c(3, 3.5, 2.5, 2), n, TRUE)
5758
)
5859

5960
# rollup

0 commit comments

Comments
 (0)