Sunday, January 24, 2016

How to change a column name in R

Syntax :

colnames(dataset name)[columnnumber] <- "New column name"


E.g

colnames(mtcars)[2] <- colnames(mtcars)[2]<-"Sample test"

I use 'mtcars' which is a default dataset available in R. You can simply type in 'mtcars' after you have logged in to R studio to get the dataset.

No comments:

Post a Comment