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
header.true <- function(df) { names(df) <- as.character(unlist(df[1,])) df[-1,] }
Test
df1 <- data.frame(c("a", 1,2,3), c("b", 4,5,6)) header.true(df1) a b 2 1 4 3 2 5 4 3 6