category-row-to-column | R Documentation |
Category to Column
category_row_na(x, .col, ..., name = "name")
category_row_regex(x, .col, pattern, name = "name")
category_row_to_column(x, .col, ..., name = "name")
.col |
the column containing category names |
... |
the columns to check for NA |
name |
a character. Name of column |
pattern |
a regex pattern to match category rows |
.data |
a dataframe |
d <- data.frame(
x = c(NA, "A", "B", NA, "A", "B"),
y = c("a", 1:2, "b", 1:2),
z = c(NA, "A", "B", NA, "A", "B")
)
category_row_na(d, y, x, z)
category_row_na(d, y, x, z, name = "small")
# Cleaning a Table with two different kinds of category rows
d <- data.frame(
x = c(NA, NA, "A", "B", NA, NA, "A", "B"),
y = c("Table a", "Male", 1:2, "Table b", "Female", 1:2),
z = c(NA, NA, "A", "B", NA, NA, "A", "B")
)
d |>
category_row_regex(y, "^Table", name = "table") |>
category_row_na(y, x, z, name = "sex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.