How to change the column names in R within aggregate function?

The column names in an R data frame are an important part of the data because by reading the column names any viewer is likely to understand the theoretical background behind it. If that name is not appropriate then we might want to change it. While using the aggregate function to calculate mean or any other statistical summary, it is possible to change that name with another name by defining the new name with list.

Example

Consider the below data frame −

set.seed(1)
x1

Changing the name of columns inside aggregate function with mean −

new_df 
Updated on: 2020-08-29T07:36:13+05:30

601 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements