data_des: Structure the Data as Table 1 Used in Publication.

View source: R/data_des.r

data_desR Documentation

Structure the Data as Table 1 Used in Publication.

Description

Category date will be presented as N(percentage). continuous data will be presented in a customized form.

Usage

data_des(
  data,
  row_var = c("vs", "mpg"),
  col_var = NULL,
  col_perc = TRUE,
  fun = c("mean", "sd"),
  comb_sym = c(" (", ")"),
  round_cate = 1,
  round_cont = 2,
  p_value = TRUE,
  test_name_cont = "t.test",
  test_name_cate = "chisq.test",
  ...
)

Arguments

data

data table.

row_var

The variable shown on the row, can't be NUll.

col_var

The variable shown on the column, can be NULL.

col_perc

When presented the category variable, the percentage should be calculated based on row or column. Default is column.

fun

The function used on continuous variable.

comb_sym

It determines how the continuous variable will be presented.

round_cate

Decimal of category variable. Default is 1.

round_cont

Decimal of continuous variable. Default is 2.

p_value

If calculate the p value

test_name_cont

test on continuous variable

test_name_cate

test on category variable

...

Arguments given to "fun"

Author(s)

Shanquan CHEN shanquan0301@gmial.com

Examples

data(mtcars)
mtcars$judge <- TRUE
mtcars$judge[3:7] <- FALSE
mtcars$judge2 <- "TRUE"
mtcars$judge2[3:7] <- "FALSE"

# continuous varialbe was shown in mean(sd)
res_tab <- data_des(data = mtcars,
         row_var = c("vs", "mpg", "wt", "gear", "judge", "judge2"),
         fun = c("mean", "sd"),
         comb_sym = c("(", ")"),
         round_cate = 2,
         round_cont = 3)

res_tab

# continuous varialbe was shown in median[25% quantile, 75% quantile]
res_tab <- data_des(data = mtcars,
         row_var = c("vs", "mpg", "wt", "gear", "judge", "judge2"),
         fun = c("median", "quantile"),
         comb_sym = c("[", "]"),
         probs = c(0.25, 0.75))

res_tab

# continuous varialbe was shown in mean[25% quantile, 75% quantile]
res_tab <- data_des(data = mtcars,
         row_var = c("vs", "mpg", "wt", "gear", "judge", "judge2"),
         col_var = "am",
         fun = c("mean", "quantile"),
         comb_sym = c("[", "]"),
         probs = c(0.25, 0.75),
         round_cate = 2,
         round_cont = 3)

res_tab


shanquan0301/DataDescription documentation built on March 13, 2024, 2:49 a.m.