reindex {mark} | R Documentation |
Reindex a data.frame
Description
Reindexes a data.frame with a reference
Usage
reindex(
x,
index = NULL,
new_index,
expand = c("intersect", "both"),
sort = FALSE
)
Arguments
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 |
Value
A data.frame
with rows of index
Examples
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")
[Package mark version 0.8.0 Index]