Learn R Programming

statar (version 0.6.2)

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, i = NULL, digits = 3)
sum_up_(x, ..., .dots, d = FALSE, w = NULL, i = NULL, digits = 3)

Arguments

x
a data.frame
...
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.
i
Condition
digits
Number of significant decimal digits. Default to 3
.dots
Used to work around non-standard evaluation.

Value

a data.frame

Examples

Run this code
library(dplyr)
N <- 100
df <- data_frame(
  id = 1:N,
  v1 = sample(5, N, TRUE),
  v2 = sample(1e6, N, TRUE)
)
sum_up(df)
sum_up(df, v2, d = TRUE)
sum_up(df, v2, d = TRUE, i = v1>3)
df %>% group_by(v1) %>% sum_up(starts_with("v"))

Run the code above in your browser using DataLab