%inorder% | R Documentation |
This function preserves the original order (sequence) of character vectors.
y %inorder% table
y |
numeric vector that contains the sequence to return |
table |
character vector, data.table, and/or tibble that has the character values to be checked within |
character vector with the characters in the original sequence
John Wallace (Stack Overflow R code), Irucka Embry
R - preserve order when using matching operators (
# Examples (from the Source)
LETTERS[1:26 %in% 4:1]
LETTERS[1:26 %inorder% 4:1]
LETTERS[1:26 %in% 3:-5]
LETTERS[1:26 %inorder% 3:-5]
data.frame(letters, LETTERS)[1:5 %in% 3:-5, ]
data.frame(letters, LETTERS)[1:5 %inorder% 3:-5, ]
library(data.table)
data.table(letters, LETTERS)[1:5 %inorder% 3:-5, ]
library(tibble)
tibble(letters, LETTERS)[1:5 %inorder% 3:-5, ]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.