table2 {tableeasy}R Documentation

Table 2

Description

' Table 2 ' was created through regression analysis to research influence factor. The four regression methods include general linear regression, logistic regression, conditional logistic regression and cox proportional hazards regression.

Usage

table2(
  x,
  y,
  data,
  y_time = NULL,
  strata = NULL,
  adj = c(),
  div = list(),
  div_num = list(),
  ref = c(),
  ref_num = c(),
  continuous = FALSE,
  case = 2,
  method = "general",
  outformat = 2
)

Arguments

x

A string. The independent variable to be summarized given as a string.

y

A string. The dependent variable to be summarized given as a string.

data

A data frame in which these variables exist.

y_time

A string. The survival time variable to be summarized given as a string. It only works when method = "cox".

strata

A string. The paired variable to be summarized given as a string. It only works when method = "con_logistic".

adj

A vector of strings, default = c(). Moderator variables to be summarized given as a character vector.

div

A list containing Positive int greater than 1 or integer vector, If a positive integer greater than 1, it is the number of factor levels when x is split by quantile statistics. If a vector of integers, it is the strategy of grouping x by quantile statistics and then merging groups.

div_num

A list containing numeric vectors, Elements in the list are custom values, and x can be split into at least two levels by elements in the list.

ref

A vector of integers. The control level of factor levels when x is split by quantile statistics.

ref_num

A vector of integers. The control level of factor levels when x is split by custom values.

continuous

Bool, default = FALSE. If default, then does not output the result when the independent variable is regarded as a continuous variable.

case

A vector of integers, default = 2. The case level of y.

method

("general", "logistic", "con_logistic", "cox"), default = "general".

outformat

1 or 2, default = 2, Output format. It only works when method = "general". The table ouput mean(sd) when outformat=1 and ouput median(IQR) when outformat=2.

Value

An object researching influence factor.

Examples

## Load Mayo Clinic Primary Biliary Cirrhosis Data
library(survival)
library(tableeasy)
data(pbc)
## Check variables
head(pbc)
##The censored data is not discussed here
pbc_full <- subset(pbc,status!=0)
pbc_full$status <- pbc_full$status-1
## Make categorical variables factors
varsToFactor <- c('status','trt','ascites','hepato','spiders','edema','stage','sex')
pbc_full[varsToFactor] <- lapply(pbc_full[varsToFactor], factor)

## Moderator variables
adj_pbc <- c('age','alk.phos','ast')

## General linear regression:
table2(x = 'albumin', y = 'bili',
       adj = c(), data = pbc_full,
       div = list(5,c(2,3)), div_num = list(c(3.2,4)),
       ref = c(2,1), ref_num = c(2),
       outformat = 2)

## Logistic regression:
table2(x ='albumin', y = 'status',
       adj = adj_pbc, data = pbc_full,
       div = list(5,c(2,3)),
       method ='logistic')

## Conditional logistic regression:
table2(x = 'albumin', y = 'status', strata = 'trt',
       adj = adj_pbc, data = pbc_full,
       div = list(5,c(2,3)),
       method = 'con_logistic')

## Cox proportional hazards regression:
table2(x = 'albumin', y = 'status', y_time = 'time',
       adj = adj_pbc, data = pbc_full,
       div = list(5,c(2,3)),
       method = 'cox')

[Package tableeasy version 1.1.2 Index]