fp_msd_class2_fp_msd_multi: fp_msd_class2_fp_msd_multi function

fp_msd_class2_fp_msd_multiR Documentation

fp_msd_class2_fp_msd_multi function

Description

This function is a wrapper for fp_msd_class2 when there are multiple variables to analyze using both fp and non-fp functions. This function will give a rough cut table 1. Given a data frame and a vector of variable names this function will apply fp_msd_class2 to each one and rbind the results into a dataframe. Additionally to adjust other parameters you can pass arguments to fp_msd_class2 as either single values (e.g. total) or as a vector the same length as the number of variables being analyzed (e.g. fp_msd_vector_tf)

Usage

fp_msd_class2_fp_msd_multi(
  data,
  indvars,
  classvar = NULL,
  fp_msd_vector_tf = NULL,
  funct1_vector = NULL,
  funct2_vector = NULL,
  var_name_vec = NULL,
  sep_var_level = TRUE,
  remove_var_dups = TRUE,
  shownval = TRUE,
  total = TRUE,
  rnd_digs_vector = NULL,
  rownvar = "Level",
  count_miss = "ifmiss",
  count_miss_lab = "Missing"
)

Arguments

data

data frame containing the data to be summarized

indvars

vector of variable names for the variables that are t be summarized. all variables must be present in the data frame

classvar

optional class variable to cross with the independent variables. this is is typically presented as a text (e.g. data$variable)vector of names to change the rows in column 1 to. This is typically what you want the individual variables that the rows represent called in the table. this must be the same length as vars. default is NULL which simply returns vars.

fp_msd_vector_tf

vector of boolean values indicating whether the variable should be 'fp' (true) or custom/msd (false). default is true

funct1_vector

a vector of the first function to use (i.e. outside the parentheses) if fp='FALSE'. default is 'mean'. if supplying different functions be sure to quote e.g. "IQR"

funct2_vector

a vector of the second function to use (i.e. inside the parentheses) if fp='FALSE'. default is 'sd'. if supplying different functions be sure to quote e.g. "IQR"

var_name_vec

a vector of variable names to use in the table. If left as null the table will contain the variable names as listed in the data frame

sep_var_level

boolean value indicating whether the variable name should be added to the table (TRUE) or not (FALSE). default is TRUE

remove_var_dups

boolean indicating whether duplicate values of the variable name should be removed (TRUE) or included (FALSE). default is TRUE

shownval

boolean indicating if the n value used after na removal should be displayed in non fp cases. this will only appear when fp=FASLE. default is TRUE

total

boolean indicating if a 'total' column should be added to the data frame. default is TRUE

rnd_digs_vector

the number of digits to round results to when fp=FALSE. default is 2

rownvar

name of the first column (second column if sep_var_level=TRUE) which contains either indvar categories or function names. default is 'Level'

count_miss

switch determining if NA values should be added to the indvar frequencies as it's own category. if this is 'ifmiss' then missing will be added. if this is 'none' then missing will be excluded and a message will show number of records removed. default is 'ifmiss'

count_miss_lab

if count_miss='ifmiss' meaning we want NA values included this argument determines what they are labeled as. default is 'Missing'

Examples

fp_msd_class2_fp_msd_multi_function()


clmacleod/highlandr documentation built on Feb. 18, 2025, 1:31 p.m.