summBy: Number summary grouped by a factor

Description Usage Arguments Details Author(s) See Also Examples

View source: R/summBy.R

Description

summ.by generates seven number summary statistics and tests normality on the fly grouped by a categorical variable.

Usage

1
2
3
4
5
6
7
summBy(x, y, data = NULL, rnd = 1, na.rm = FALSE, print.table = TRUE)

## S3 method for class 'list'
summBy(x, y, data = NULL, rnd = 1, na.rm = FALSE, print.table = TRUE)

## S3 method for class 'data.frame'
summBy(x, y, data = NULL, rnd = 1, na.rm = FALSE, print.table = TRUE)

Arguments

x

a numeric object

y

a factor or character object

data

a data frame object (Optional)

rnd

specify rounding of numbers. See round.

na.rm

A logical value to specify missing values, <NA> in the table

print.table

logical value to display formatted outputs

Details

Similar to summ output, summBy reports number of observations in the dataset, missing data, seven number summary statistics, coefficient of variation (CV.) and normality test. Normality test is perfomed by Shapiro-Wilk Normality Test. See more at shapiro.test.

ANNOTATIONS

Obs. = observation

NA. = missing data

Mean = Mean value

Std.Dev = Standard deviation

Median = Median value

Q1 = First quartile or percentile

Q3 = Third quartile or percentile

Min = Minimum value

Max = Maximum value

Normal.test = test by Shapiro-Wilk Normality Test

If the second variable has two levels of category, it performs either Student's t-test t.test or Wilcoxon test (Mann-Whitney's test) wilcox.test. If more than two levels, ANOVA aov or Kruskal-Wallis rank sum test kruskal.test is carried out to test the difference between different groups.

Author(s)

Myo Minn Oo (Email: dr.myominnoo@gmail.com | Website: https://myominnoo.github.io/)

See Also

summ, tab, xtab

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
# single x variable
summBy(age, education, infert)
summBy(infert$age, infert$education)

# multiple variables
summBy(c(age, parity, stratum), education, infert)

# whole dataframe
summBy(infert, education)
summBy(iris, Species)

# variables labels
infert.new <- labelVars(infert,
                c(age, case, spontaneous, education),
                c("age of patient",
                  "case (yes or no)",
                  "spontaneous labor",
                  "education of patient"))
infert.new <- keep(infert.new, age, case, spontaneous, education)
codebook(infert.new)
summBy(infert.new, education)

## End(Not run)

myominnoo/mStats_beta documentation built on Feb. 29, 2020, 8:17 a.m.