statar (version 0.1.1)

sum_up: Gives summary statistics (corresponds to Stata command summarize)

Description

Gives summary statistics (corresponds to Stata command summarize)

Usage

sum_up(x, ..., d = FALSE, w = NULL, na.rm = TRUE, by = NULL,
  digits = 3)

sum_up_(x, vars, d = FALSE, w = NULL, na.rm = TRUE, by = NULL, digits = 3)

Arguments

x
a data.table
...
Variables to include. Defaults to all non-grouping variables. See the select documentation.
d
Should detailed summary statistics be printed?
w
Weights. Default to NULL.
na.rm
A boolean. default to TRUE
by
Groups within which summary statistics are printed. Default to NULL. See the select documentation.
digits
Number of significant decimal digits. Default to 3
vars
Used to work around non-standard evaluation.

Examples

Run this code
library(data.table)
N <- 100
DT <- data.table(
  id = 1:N,
  v1 = sample(5, N, TRUE),
  v2 = sample(1e6, N, TRUE)
)
sum_up(DT)
sum_up(DT, v2, d = TRUE)
sum_up(DT, starts_with("v"), by = v1)
sum_up(DT, by = v1)

Run the code above in your browser using DataLab