Skip to content

kvegesan-stjude/sjTabone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sjTabone

We developed this package to help create a summary table one for publications. There are other excellent options like DescTools and tableone that can help you do create the same summaries. We created this package so we could customize the methods and display options.

When using this package, categorical variables need to be explicitly converted to factors. Comparisons between groups are done using the following methods:

Shapiro-Wilk test is used to test the normality of variables.

Installation


devtools::install_github("https://github.com/kvegesan-stjude/sjTabone")


Usage

Let's create some test data with an outcome variable, one categorical variable, one normally distributed variable, and one non-normal variable:

library(sjTabone)
data <-
  as.data.frame(list(
    subject.id=seq(1:100),
    outcome = sample(
      c('case', 'control'),
      size = 100,
      replace = TRUE,
      prob = c(0.3, 0.7)
    ),
    sex = sample(
      c('Male', 'Female'),
      size = 100,
      replace = TRUE,
      prob = c(0.5, 0.5)
    ),
    age = log(rlnorm(
      100, meanlog = 28, sdlog = 4
    )),
    bmi = c(log(rlnorm(
      70, meanlog = 20, sdlog = 2
    )), log(rlnorm(
      30, meanlog = 32, sdlog = 2
    )))
  ))

Cast the categorical variable as as factor. This step is to avoid the cases where numeric factors are treated as continuous variables.

library(dplyr)
catvars<-c('sex')
data<-data%>%mutate_at(catvars, factor)

We can now call sjTabone on this dataset and save the table to a document called 'Summary1':

sumry<-sjTabone(data,myvars = colnames(data),idcol = 'subject.id',strata = 'outcome')

write_tabone(sumry,'Summary1')

This is an example of the output.

Summary

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages