Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

row_to_names

Elevate a row to be the column names of a data.frame.


Description

Elevate a row to be the column names of a data.frame.

Usage

row_to_names(dat, row_number, remove_row = TRUE, remove_rows_above = TRUE)

Arguments

dat

The input data.frame

row_number

The row of dat containing the variable names

remove_row

Should the row row_number be removed from the resulting data.frame?

remove_rows_above

If row_number != 1, should the rows above row_number - that is, between 1:(row_number-1) - be removed from the resulting data.frame?

Value

A data.frame with new names (and some rows removed, if specified)

Examples

x <- data.frame(X_1 = c(NA, "Title", 1:3),
                X_2 = c(NA, "Title2", 4:6))
x %>%
  row_to_names(row_number = 2)

janitor

Simple Tools for Examining and Cleaning Dirty Data

v2.1.0
MIT + file LICENSE
Authors
Sam Firke [aut, cre], Bill Denney [ctb], Chris Haid [ctb], Ryan Knight [ctb], Malte Grosser [ctb], Jonathan Zadra [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.