Modifying column names
Sometimes you want to rename your colums. You could do this by creating copies of the columns with new names, but you can also directly get and set the column names of a data frame, using the function colnames().
The dplyr library has a rename() function, which can also be used. Remember the cheatsheet.
Este ejercicio forma parte del curso
Helsinki Open Data Science
Instrucciones del ejercicio
- Print out the column names of
learning2014 - Change the name of the second column to 'age'
- Change the name of 'Points' to 'points'
- Print out the column names again to see the changes
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# learning2014 is available
# print out the column names of the data
colnames(learning2014)
# change the name of the second column
colnames(learning2014)[2] <- "age"
# change the name of "Points" to "points"
# print out the new column names of the data