| first_row_as_names | R Documentation |
Sets the first row of a data frame as variable names and deletes it. In case of NA, numeric values or empty characters in the first row, the old names are kept.
first_row_as_names(data_frame)
data_frame |
A data frame for which to set new variable names. |
Returns a data frame with renamed variables.
# Example data frame
my_data <- data.frame(
var1 = c("id", 1, 2, 3),
var2 = c(NA, "a", "b", "c"),
var3 = c("value", 1, 2, 3),
var4 = c("", "a", "b", "c"),
var5 = c(1, 2, 3, 4))
my_data <- my_data |> first_row_as_names()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.