View source: R/groupsummary.h.R
groupsummary | R Documentation |
Group data by categorical variables and calculate summary statistics
groupsummary(
data,
groupVars,
sumVars,
statistics = list("sum", "mean", "n"),
dateVar,
dateFormat = "ymd",
timeAggregation = "day",
showMissing = FALSE,
addPercentage = TRUE,
sortBy = "groups"
)
data |
The data as a data frame. |
groupVars |
Variables to group by (categorical or date). |
sumVars |
Numeric variables to calculate statistics for each group. |
statistics |
. |
dateVar |
Select the date variable from group variables to apply date formatting. |
dateFormat |
. |
timeAggregation |
. |
showMissing |
Include groups with missing values in the summary. |
addPercentage |
Add percentage of total for sum values. |
sortBy |
. |
A results object containing:
results$todo | a html | ||||
results$dateInfo | a html | ||||
results$summaryTable | a table | ||||
results$plot | an image | ||||
Tables can be converted to data frames with asDF
or as.data.frame
. For example:
results$summaryTable$asDF
as.data.frame(results$summaryTable)
# Group by one or more categorical variables and sum numeric variables
groupsummary(
data = mydata,
groupVars = c("Category", "Group"),
sumVars = c("Value1", "Value2")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.