round multiple columns in r

To round multiple columns in R, you can use the round() function along with the mutate_at() function from the dplyr package. Here are the steps to accomplish this:

  1. Load the required packages:
library(dplyr)
  1. Select the columns you want to round:
columns_to_round <- c("column1", "column2", "column3")
  1. Use the mutate_at() function to apply the round() function to the selected columns:
your_dataframe <- your_dataframe %>%
  mutate_at(vars(columns_to_round), round)

This code snippet will round the columns specified in columns_to_round in your dataframe your_dataframe. The round() function will round the values in each specified column to the nearest whole number.

Please note that you need to replace "column1", "column2", and "column3" with the actual names of the columns you want to round in your dataframe. Additionally, make sure you have the dplyr package installed before running this code.