rdesc: Robust Descriptives

View source: R/rdesc.h.R

rdescR Documentation

Robust Descriptives

Description

Robust Descriptives

Usage

rdesc(
  data,
  vars,
  splitBy = NULL,
  mean = TRUE,
  trim = TRUE,
  tr = 0.2,
  win = FALSE,
  wl = 0.2,
  mest = FALSE,
  bend = 1.28,
  med = FALSE
)

Arguments

data

the data as a data frame

vars

a vector of strings naming the variables in data of interest

splitBy

a string naming the variable in data to split the data by

mean

TRUE (default) or FALSE, provide a 'normal' arithmetic mean

trim

TRUE (default) or FALSE, provide a trimmed mean

tr

a number between 0 and 0.5 (default: 0.2); the proportion of measurements to trim from each end when producing trimmed means

win

TRUE or FALSE (default), provide a 'Winsorized' mean

wl

a number between 0 and 0.5 (default: 0.2); the level of 'winsorizing' when producing winsorized means

mest

TRUE or FALSE (default), provide an 'M-estimated' value

bend

a number (default: 1.28), the bending constant to use when using M-estimators

med

TRUE or FALSE (default), provide medians

Value

A results object containing:

results$table the table of descriptives

Tables can be converted to data frames with asDF or as.data.frame. For example:

results$table$asDF

as.data.frame(results$table)

Examples


data('eurosoccer', package='WRS2')

SpainGermany <- subset(eurosoccer, eurosoccer$League == 'Spain' | eurosoccer$League == 'Germany')
SpainGermany <- droplevels(SpainGermany)

walrus::rdesc(
    data = SpainGermany,
    vars = "GoalsGame",
    splitBy = "League",
    med = TRUE)

#
#  ROBUST DESCRIPTIVES
#
#  Robust Descriptives
#  ----------------------------------------------------------
#                                                    SE
#  ----------------------------------------------------------
#    GoalsGame    Germany    Mean            1.46     0.105
#                            Trimmed mean    1.45    0.1341
#                            Median          1.43    0.1599
#
#                 Spain      Mean            1.45     0.101
#                            Trimmed mean    1.33    0.0601
#                            Median          1.30    0.0766
#  ----------------------------------------------------------
#


walrus documentation built on Sept. 8, 2022, 9:07 a.m.