| swap_help | R Documentation |
Swap by Row Index, Column Index, Element Index, and Atomic Value.
swap_help()
swap(x, s1, s2, type = "i")
swap_vals(x, v1, v2)
swap_elts(x, i1, i2)
swap_rows(x, i1, i2)
swap_cols(x, i1, i2)
x |
A non-empty data.frame, matrix, vlist (?VLS), or an atomic object of any dimension. |
from, to |
Uniquely valued non-zero whole number vectors indexing source ( |
old |
A uniquely valued atomic vec of values to be replaced. |
new |
An atomic vec of replacement values. |
dim |
Dimension on which swapping occurs. |
all |
|
An object of the same class and dimensions as x.
swap(): Swap elements of x either by index (when type == "i") or by value (when type == "v").
swap_vals(): Swap elements of x either by value, meaning that elements of x matching v1[i] are replaced by v2[i] and vice versa.
swap_elts(): Swap elements of x by index, meaning that element i1[i] of x is replaced by element i2[i] of and vice versa.
swap_rows(): Swap rows of x by index, meaning that row i1[i] of x is replaced by row i2[i] of x and vice versa.
swap_cols(): Swap columns of x by index, meaning that column i1[i] of x is replaced by column i2[i] of x and vice versa.
Other forks:
case(),
fork_help()
AF <- LETTERS[1:6]
M6 <- matrix(1:36, nrow = 6)
i1 <- 1:3
i2 <- 6:4
v1 <- c("A", "B", "C")
v2 <- c("a", "b", "c")
AF
swap_vals(AF, v1, v2)
swap_elts(AF, i1, i2)
swap(AF, v1, v2, type = "v")
swap(AF, i1, i2, type = "i")
M6
swap_rows(M6, i1, i2)
swap_cols(M6, i1, i2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.