reindex | R Documentation |
Reindexes a data.frame with a reference
reindex(
x,
index = NULL,
new_index,
expand = c("intersect", "both"),
sort = FALSE
)
x |
A data.frame |
index |
The column name or number of an index to use; if |
new_index |
A column vector of the new index value |
expand |
Character switch to expand or keep only the values that intersect (none), all values in x or index, or retain all values found. |
sort |
Logical, if |
A data.frame
with rows of index
iris1 <- head(iris, 5)
iris1$index <- 1:5
reindex(iris1, "index", seq(2, 8, 2))
reindex(iris1, "index", seq(2, 8, 2), expand = "both")
# Using letters will show changes in rownames
iris1$index <- letters[1:5]
reindex(iris1, "index", letters[seq(2, 8, 2)])
reindex(iris1, "index", seq(2, 8, 2))
reindex(iris1, "index", seq(2, 8, 2), expand = "both")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.