noclass_by_dich_fp: noclass_by_dich_fp function

View source: R/summary.R

noclass_by_dich_fpR Documentation

noclass_by_dich_fp function

Description

given a suite of binary variables only this function creates a data frame of frequencies and percents formatted as n(

Usage

noclass_by_dich_fp(
  aggvars,
  data_to_use,
  cntfunc = sum,
  pctfunc = mean,
  catname = "Total",
  fieldnames = "none",
  cols = TRUE,
  pct = "none",
  cnt = "none",
  transpose_result = TRUE,
  varlist_name = "Variable",
  total = TRUE,
  digs = 2
)

Arguments

aggvars

a vector of variable names for those variables that you want aggregated. these must all be 0/1 binary variables

data_to_use

the data frame than contains the aggvars and byvar

cntfunc

the function to use for the calculation outside of the parentheses. default is sum

pctfunc

the function to use inside the parentheses. default is mean

catname

the name given to the first column which contains the names of the variables supplied. default is 'Total'

fieldnames

vector of names to replace variable names supplied above in aggvars. if agvars = c("var1","var2","var3") and fiednames = c("do","ray","me") then the first variable in the returned dataset will be "do","ray","me"

cols

boolean make the rows the same name as aggvars. default is TRUE

pct

switch indicating if the results should be formatted as a percent. changing this variable to anything other than 'none' will activate the switch and rename the column to that value. default is 'none'

cnt

switch indicating if the results should be formatted as a percent. changing this variable to anything other than 'none' will activate the switch and rename the column to that value. default is 'none'

transpose_result

transposes the result so that rows are variables and columns are class variabe values. default is TRUE

varlist_name

the name given to the first column of the data frame which contains the list of variables in the aggvars binary suite. default is 'variable'

total

boolean indicating if a total column should be produced. default is TRUE

digs

the number of digits to which the results will be rounded

Examples

class_by_dich_fp_function()

clmacleod/highlandr documentation built on Oct. 11, 2023, 8:04 p.m.