MyNixOS website logo
Description

Providing Demographic Table with the P-Value, Standardized Mean Difference Value.

The Demographic Table in R combines contingency table for categorical variables, mean and standard deviation for continuous variables. t-test, chi-square test and Fisher's exact test calculated the p-value of two groups. The standardized mean difference were performed with 95 % confident interval, and writing table into document file.

demoGraphic

The goal of demoGraphic is providing five main function cont_table(), cat_table(), demo_table(), smd_plot(), mydocx(). These are used to calculate the mean, standard deviation, pvalue was performanced on t-test for continuous variables, the contigency table and propotion, chi square test or fisher exact test were performanced to get p value, the standardized difference between two groups.

Installation

You can install the released version of demoGraphic from CRAN with:

install.packages("demoGraphic")

Example

This is a basic example which shows you how to solve a common problem:

# Create data set

set.seed(2018)

group <-round(abs(rnorm(500)*10),0) %% 2

cont_1 <-round(abs(rnorm(500)*10),0)
cont_2 <-round(abs(rnorm(500)*50),0)
cont_3 <-round(abs(rnorm(500)*30),0)

cat_binary <-round(abs(rnorm(500)*10),0) %% 2
cat_multi_1 <-round(abs(rnorm(500)*10),0) %% 3
cat_multi_2 <-round(abs(rnorm(500)*10),0) %% 4
cat_multi_3 <-round(abs(rnorm(500)*10),0) %% 5


data<-data.frame(group, cont_1, cont_2, cont_3, cat_binary, cat_multi_1, cat_multi_2, cat_multi_3)
data$group <- factor(data$group, levels = c(0,1), labels = c("Unexposed","Exposed"))
data[,c(6,7,8)] <- lapply(data[,c(6,7,8)], as.factor)


# ===================================================
# 1. testing continuous variable

# 1a. Test one variable

t <- cont_table("cont_2","group", data)


t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p


# write smd table with file name smd_table.docx and save it in directory
mydocx(t$smd_table,"smd_table") 


#=====================================

# 1b. Test multiple variables

var <- c("cont_1","cont_2","cont_3")


t <- cont_table(var,"group", data)

t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p

# write smd table with file name smd_table.docx and save it in directory
mydocx(t$smd_table,"smd_table") 


# ===================================================
# 2. testing catgorical variable

# 2a. Test one variable

t <- cat_table("cat_binary","group", data)


t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p

# write smd table with file name smd_table.docx and save it in directory
mydocx(t$smd_table,"smd_table") 


#=================================


# 2b. Test multiple variables

var <- c("cat_binary","cat_multi_1","cat_multi_2","cat_multi_3")

t <- cat_table(var,"group", data)

t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p

# write smd table with file name smd_table.docx and save it in directory
mydocx(t$smd_table,"smd_table") 



#======================================

# 3. Test demo_table function (continuous and categorical variables together)
# 3a. One variable

t <- demo_table("cat_binary","group", data)

t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p

# write smd table with file name smd_table.docx and save it in directory
mydocx(t$smd_table,"smd_table") 


#===================================

# 3b. Multiple variables


var <- c("cat_binary","cont_1","cont_2","cont_3","cat_multi_1","cat_multi_2","cat_multi_3")

t <- demo_table(var,"group", data)

t$smd_table # smd table
t$demo_table # demographic table


p <- smd_plot(t$smd_table) # plot smd 
p


# write smd table with file name smd_table.docx and save it in directory
mydocx(t$demo_table,"demo_table") 


Metadata

Version

0.1.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows