View source: R/rows-to-names.R
rows_to_names | R Documentation |
Make Names from rows
rows_to_names(
x,
rows,
sep = "_",
na.sep = sep,
na.rm = TRUE,
all.cols = TRUE,
regex = "^(\\.{3}|X\\d+)"
)
rows2header(
x,
rows,
sep = "_",
na.sep = sep,
na.rm = TRUE,
all.cols = TRUE,
regex = "^(\\.{3}|X\\d+)"
)
x |
A data frame |
rows |
rows to make the header from |
sep |
seperator. Defaults to "_". |
na.sep |
seperator to be used for NAs if |
na.rm |
a logical. Remove NAs |
all.cols |
Should all columns be renamed? |
regex |
A regular expression to select columns to rename if |
d <- data.frame(
a = c("Total", "0 - 20", 10),
b = c("Total", "20 - 40", 8),
c = c("Total", "40 - 60", 6)
)
# Rename all columns
rows_to_names(d, 1:2)
# Do not rename column "b"
rows_to_names(d, 1:2, all.cols = "b")
# Do not rename columns 2:3
rows_to_names(d, 1:2, all.cols = 2:3)
# Rename only columns starting with `...`
rows_to_names(d, 1:2, all.cols = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.