View source: R/round_numeric.R
round_numeric | R Documentation |
This function rounds numeric columns in a data frame to a specified number of digits.
round_numeric(x, digits)
x |
A data frame. |
digits |
Number of digits to round to. Defaults to 0. |
A modified data frame with rounded numeric columns.
round
# 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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.