Learn R Programming

fmtr (version 1.0.1)

fattr: Set formatting attributes

Description

Assign formatting attributes to a vector

Usage

fattr(x, format = NULL, width = NULL, justify = NULL, keep = TRUE)

Arguments

x

The vector to assign attributes to.

format

The format to assign to the format attribute. Format can be a formatting string, a named vector decode, a vectorized formatting function, or a formatting list.

width

The desired width of the formatted output.

justify

Justification of the output vector. Valid values are 'none', 'left', 'right', 'center', or 'centre'.

keep

Whether to keep any existing formatting attributes and transfer to the new vector. Default value is TRUE.

Value

The vector with formatting attributes applied.

Details

The fattr function is a convenience function for assigning formatting attributes to a vector. The function accepts parameters for format, width, and justify. Any formatting attributes assigned to a vector can be applied using fapply or fdata.

See Also

fdata to apply formats to a data frame, fapply to apply formats to a vector. See FormattingStrings for documentation on formatting strings.

Examples

Run this code
# NOT RUN {
# Create vector
a <- c(1.3243, 5.9783, 2.3848)

# Assign format attributes
a <- fattr(a, format = "%.1f", width = 10, justify = "right")

# Apply format attributes
fapply(a)
# }

Run the code above in your browser using DataLab