powered by
Elevate a row to be the column names of a data.frame.
row_to_names(dat, row_number, ..., remove_row = TRUE, remove_rows_above = TRUE)
A data.frame with new names (and some rows removed, if specified)
The input data.frame
The row of dat containing the variable names or the string "find_header" to use find_header(dat=dat, ...) to find the row_number.
dat
"find_header"
find_header(dat=dat, ...)
Sent to find_header(), if row_number = "find_header". Otherwise, ignored.
find_header()
row_number = "find_header"
Should the row row_number be removed from the resulting data.frame?
row_number
If row_number != 1, should the rows above row_number - that is, between 1:(row_number-1) - be removed from the resulting data.frame?
row_number != 1
1:(row_number-1)
Other Set names: clean_names(), find_header(), mu_to_u
clean_names()
mu_to_u
x <- data.frame(X_1 = c(NA, "Title", 1:3), X_2 = c(NA, "Title2", 4:6)) x %>% row_to_names(row_number = 2) x %>% row_to_names(row_number = "find_header")
Run the code above in your browser using DataLab