Learn R Programming

eatTools (version 0.7.8)

print_and_capture: Easy integration of (small) tables into (error) messages

Description

Some (error) messages are more understandable if small (frequency) tables are used for clearness. The function simplifies integration of these tables. The function is intended to be used in combination with message, stop, or cat, for example.

Usage

print_and_capture (x, spaces = 0)

Value

a string which may be combined with messages

Arguments

x

The object which should be integrated. Normally, a (small) table or data frame.

spaces

Number of spaces between left border and the table

Examples

Run this code
frequency.table <- as.table(matrix(c(12,0,5,7),2,2))
attr(frequency.table, "dimnames") <- list("sex" = c("male", "female"),
        "migration" = c(TRUE, FALSE))
message("Some combinations of variables with zero observations: \n",
        print_and_capture(frequency.table, spaces = 5))

Run the code above in your browser using DataLab