round_numeric: This function rounds numeric columns in a data frame to a...

View source: R/round_numeric.R

round_numericR Documentation

This function rounds numeric columns in a data frame to a specified number of digits.

Description

This function rounds numeric columns in a data frame to a specified number of digits.

Usage

round_numeric(x, digits)

Arguments

x

A data frame.

digits

Number of digits to round to. Defaults to 0.

Value

A modified data frame with rounded numeric columns.

See Also

round

Examples

# Create a sample data frame
data <- data.frame(
  numeric_col1 = c(1.234, 2.345, 3.456),
  numeric_col2 = c(4.567, 5.678, 6.789),
  non_numeric_col = c("A", "B", "C")
)
attr(data, "my") <- "It keeps all the attributes!"
# Round numeric columns in the data frame
round_numeric(data, digits = 2)
attr(data, "my") 

jazznbass/wmisc documentation built on Oct. 29, 2024, 5:42 p.m.