To rename the first character of all column names in a data frame using dplyr, we can use the rename_all() function along with the str_to_title() function from the stringr package.
Here's an example code snippet:
main.r126 chars8 lines
In this example, we first create a sample data frame df with some columns named in all lowercase. Then, we use rename_all() to apply str_to_title() function to each column name, which will capitalize the first character of every word in the name.
The resulting output will be a new data frame with the column names with the first character capitalized:
main.r68 chars5 lines
gistlibby LogSnag