I have a dirty dataset that I could not read it with header = T. After I read and clean it, I would like to use the now first row data as the column name. I tri
header = T
Sam Firke's ever useful package janitor has a function especially for this: row_to_names.
row_to_names
Example from his documentation:
library(janitor) x <- data.frame(X_1 = c(NA, "Title", 1:3), X_2 = c(NA, "Title2", 4:6)) x %>% row_to_names(row_number = 2)