table3 {tableeasy}R Documentation

Table 3

Description

Creates 'Table 3' which is about stratified analysis. The three regression methods include general linear regression, logistic regression and cox proportional hazards regression.

Usage

table3(
  x,
  y,
  data,
  split_var,
  y_time = NULL,
  adj = c(),
  split_div = list(),
  outformat = 4,
  method = "general"
)

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.

split_var

A vector of strings. Strata variables to be summarized given as a character vector.

y_time

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

adj

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

split_div

A list containing numeric vectors or a vector of integers that are summarized given as a string, default = list(). If default, it represents the strata variables are split by median or it is itself a categorical variable. If the element of list is a numeric vector, it represents the strata variables are split by custom values. And if the element of list is a vector of integers that are summarized given as a string, it represents the strata variables are split by quantile statistics.

outformat

1 or 2 or 3 or 4, default = 4. Output format.

method

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

Value

An object about stratified analysis.

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')
## Converts the continuous variables named 'albumin' to a categorical variable named 'albumin_2'.
albumin_2 <- div_quantile('albumin',div = c(2),pbc_full)
pbc_full <- data.frame(pbc_full,'albumin_2' = albumin_2)

## General linear regression:
table3(x = 'albumin_2', y = 'bili',
       adj = c(), data = pbc_full,
       split_var = c('age','alk.phos','ast','trt'), split_div = list(),
       outformat = 1)

## Logistic regression:
table3(x = 'albumin_2', y = 'status',
       adj = adj_pbc, data = pbc_full,
       split_var = c('age','alk.phos','ast','trt'), split_div = list(c('2','3'),c('3')),
       outformat = 2,method = 'logistic')

## Cox proportional hazards regression:
table3(x = 'albumin_2',y = 'status',y_time = 'time',
       adj = adj_pbc,data = pbc_full,
       split_var = c('age','alk.phos','ast','trt'), split_div = list(c(45),c(1500,1700),c(),c()),
       outformat = 3,method = 'cox')

[Package tableeasy version 1.1.2 Index]