Learn R Programming

lcc (version 3.2.2)

formatColumn: Format Columns for Print

Description

This internal helper function is used to format the columns of a data frame for printing, specifically for use within the `print.anova.lcc` function. It applies special formatting rules based on the column name, such as rounding and special handling of small p-values.

Usage

formatColumn(column, colName)

Value

A vector with the same length as `column`, where each element has been formatted according to the column-specific rules.

Arguments

column

A vector representing a column from a data frame.

colName

A string indicating the name of the column, which determines the formatting rules to be applied.

Details

The function specifically handles the following columns: - "p-value": Rounds the values to four decimal places, and represents values less than 0.0001 as "<.0001". - "AIC", "BIC", "logLik", "L.Ratio": Applies `zapsmall` for formatting. Other columns are returned without changes.

Examples

Run this code
data <- data.frame(
  pvalue = c(0.00005, 0.0234, 0.5),
  AIC = c(123.4567, 234.5678, 345.6789)
)
data$pvalue <- formatColumn(data$pvalue, "p-value")
data$AIC <- formatColumn(data$AIC, "AIC")

Run the code above in your browser using DataLab