remix: Remix and describe.

Description Usage Arguments Value Note Author(s) See Also Examples

View source: R/remix.r

Description

A quick and easy function for describing datasets.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  remix(formula = cbind(...) ~ ., data = NULL, funs =
  c(mean, sd, quantile, n, na), ..., cum = FALSE, margin =
  0:2, addmargins = FALSE, useNA = c("no", "ifany",
  "always"), propNA = TRUE, revert = FALSE, method =
  c("pearson", "kendall", "spearman"), times = NULL,
  followup = FALSE, test = FALSE, test.summarize =
  test.summarize.auto, test.survival =
  test.survival.logrank, test.tabular = test.tabular.auto,
  show.test = display.test, plim = 4, show.method = TRUE,
  label = FALSE)

Arguments

formula

a formula (see Details).

data

a data.frame.

funs

functions for describing numeric variable. Can be c(fun1, fun2, fun3) or c("fun1", "fun2", "fun3") or a list.

...

further arguments (all passed to funs), for example na.rm = TRUE

cum

should cumulated frequencies be reported?

margin

index, or vector of indices to generate proportion in frequency tables (0: cell, 1: row, 2: col).

addmargins

whether to add margins

useNA

whether to include NA as a level (factor)

propNA

whether to include NA in proportion calculation

revert

whether to regroup factors or numeric variables when crossing factor with numeric variables

method

a character string indicating which correlation coefficient is to be used. One of "pearson", "kendall", or "spearman", can be abbreviated.

times

vector of times (see ?summary.survival un package survival)

followup

whether to display follow-up time

test

whether to perform tests

test.summarize

a function of two arguments (continuous variable and grouping variable) used to compare continuous variable, that return a list of two components : p.value and method (the test name). See test.summarize.auto, test.summarize.kruskal, test.summarize.oneway.equalvar, or test.summarize.unequalvar for example of such functions. Users can provide their own function.

test.survival

a function of one argument (a formula) used to compare survival estimations, that returns the same components as created by test.summarize. See test.survival.logrank. Users can provide their own function.

test.tabular

a function of three arguments (two categorical variables and a logical na) used to test association between two factors, that returns the same components as created by test.summarize. See test.tabular.auto and test.tabular.fisher. Users can provide their own function.

show.test

a function used to display the test result. See display.test.

plim

number of digits for the p value

show.method

should display the test name?

label

whether to display labels of variables (using label in package Hmisc)

Value

A remix object, basically a list with descriptive tables. It uses ascii package for printing output, and can be use with ascii function.

Note

The formula has the following format: x_1 + x_2 + ... ~ y_1 + y_2 + ...

There are a couple of special variables: ... represents all other variables not used in the formula and . represents no variable, so you can do formula = var1 ~ ..

If var1 is numeric, var1 ~ . produce a summary table using funs. If var1 is a factor, var1 ~ . produce a frequency table. If var1 is of class Surv, var1 ~ . produce a table with the estimates of survival at times. If var1 is numeric and var2 is numeric, var1 ~ var2 gives correlation. if var1 is numeric and var2 is a factor, var1 ~ var2 produce a summary table using funs according to the levels of var2. If var1 is a factor and var2 is a factor, var1 ~ var2 produce a contingency table. If var1 is of class Surv and var2 is a factor, var1 ~ var2 produce a table with the estimates of survival for each level of var2.

You can group several variables of the same type (numeric or factor) together with cbind(var1, var2, var3), they will be grouped in the same table. cbind(...) works (ie regroups all variables of the same type).

Author(s)

David Hajage, inspired by the design and the code of summary.formula (Hmisc package, FE Harrell) and cast (reshape package, H Wickham).

See Also

cast (reshape) and summary.formula (Hmisc).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
parwidth <- getOption("width")
options(width = 100)

library(remix)
remix(data = iris)
remix(cbind(...) ~ ., iris[, sapply(iris, is.numeric)], funs = c(median, mad, min, max))
remix(cbind(Sepal.Length, I(Sepal.Width^2)) ~ Species, iris, funs = quantile, probs = c(1/3, 2/3))
remix(Sepal.Length + Sepal.Width ~ Petal.Length + Petal.Width, iris)
remix(cbind(Sepal.Length, Sepal.Width) ~ cbind(Petal.Length, Petal.Width), iris)
remix(... ~ ., esoph, cum = TRUE)
remix(alcgp ~ tobgp, esoph, cum = TRUE)
remix(Surv(time, status) ~ x, data = aml, times = seq(0, 120, 12))

options(width = parwidth)

remix documentation built on May 29, 2017, 5:50 p.m.

Related to remix in remix...