qwickr.cat: Summarize for categorical data

View source: R/qwickr.cat.R

qwickr.catR Documentation

Summarize for categorical data

Description

Run descriptive summaries for categorical data with the option to include hypothesis testing using the Chi Square test or Fisher's Exact test as appropriate.

Usage

qwickr.cat(x, outcomevar="", groupvar="", timevar="", specgroups=NULL, 
          filesuffix="", t.title="", genpvalues=T, runpairwise=F, 
          exportfile=c(), exportpath="")

Arguments

x

Data frame

outcomevar

Name of outcome variable (string)

groupvar

Name of the group variable (string)

timevar

Name of the time variable (string)

specgroups

Do you want to compare a subset of groups within your dataset? Specify the group names here. For example, specgroups=c("Group A", "Group B", "Group C"). If NULL, all groups will be included in the analysis.

filesuffix

A string to be appended to the name of the returned .csv or .doc file

t.title

Table title. Exported together with a dataframe of the output as a list. This list can then be exported to Word using the q.write.to.word() command

genpvalues

Should a Chi Square or Fisher's Exact test be performed? T/F. If true, the function will determine which test to perform

runpairwise

Run pairwise comparisons for each unique group pair? T/F

exportfile

Export the output to file? Options: c(".csv", ".doc"). See q.write.to.word, stats::write.csv

exportpath

Path relative to the working directory where exported files will be saved e.g. "OUTPUT" Do not begin or end with a backslash. If left empty, file will be exported to the working directory.

Details

The function will automatically determine whether to use Chi Square or Fisher's Exact test based on the nature of the data.

Value

Returns a data frame of counts and percentages for each study arm and an associated p-value for each study time point in a repeated measures design.

Author(s)

Abdul Malik Sulley <asulley@uwo.ca> May 7, 2020

See Also

stats::fisher.test(), q.write.to.word, utils::write.csv

Examples

group <- rep(c("A", "B"), 10)
gender <- rep(c(1,1,0,0), 5)
time <- rep(1, 10)
df <- data.frame(group, gender, time)
qwickr.cat(x=df, outcomevar="gender", groupvar = "group", timevar = "time")

qwickmalik/qwickr documentation built on March 30, 2022, 2:59 p.m.