| data_rotate | R Documentation |
This function rotates a data frame, i.e. columns become rows and vice versa.
It's the equivalent of using t() but restores the data.frame class,
preserves attributes and prints a warning if the data type is
modified (see example).
data_rotate(data, rownames = NULL, colnames = FALSE, verbose = TRUE)
data_transpose(data, rownames = NULL, colnames = FALSE, verbose = TRUE)
data |
A data frame. |
rownames |
Character vector (optional). If not |
colnames |
Logical or character vector (optional). If |
verbose |
Toggle warnings. |
A (rotated) data frame.
Add a prefix or suffix to column names: data_addprefix(), data_addsuffix()
Functions to reorder or remove columns: data_reorder(), data_relocate(),
data_remove()
Functions to reshape, pivot or rotate data frames: data_to_long(),
data_to_wide(), data_rotate()
Functions to recode data: rescale(), reverse(), categorize(),
recode_values(), slide()
Functions to standardize, normalize, rank-transform: center(), standardize(),
normalize(), ranktransform(), winsorize()
Split and merge data frames: data_partition(), data_merge()
Functions to find or select columns: data_select(), extract_column_names()
Functions to filter rows: data_match(), data_filter()
x <- mtcars[1:3, 1:4]
x
data_rotate(x)
data_rotate(x, rownames = "property")
# use values in 1. column as column name
data_rotate(x, colnames = TRUE)
data_rotate(x, rownames = "property", colnames = TRUE)
# use either first column or specific column for column names
x <- data.frame(a = 1:5, b = 11:15, c = 21:25)
data_rotate(x, colnames = TRUE)
data_rotate(x, colnames = "c")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.