How to change the column names in a dataframe in R?
A data frame is a structure having 2 dimensions which contains data in the form or rows and columns.It is like a spreadsheet or dictionaries of series. To create a dataframe in R, we use data.frame function which combines all the input data and creates a dataframe.
In R, colnames() function can be used to change the column names.Let us create a dataframe to change the column names
X <- data.frame(col1=1:3, col2=rnorm(3))
Now to change the column names
colnames(X) <- c("good", "better")
X