Validate selected elements from a character vector using a variety of selection mechanisms: logical, names, or numerical indexes
elements to select from
A character vector from which to select elements (such as row names or column names)
This function is especially useful for selecting rows or columns from data frames, while providing informative error messages
elements for selection are specified incorrectly.
A character vector with elements that were selected from
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# Define some "column names" cnames <- letters[1:5] cnames # Select the 1st and 3rd column names using a variety of approaches selectElements(c("a", "c"), cnames) selectElements(c(1, 3), cnames) selectElements(c(TRUE, FALSE, TRUE, FALSE, FALSE), cnames) # Select the 1st, 3rd, and 1st columns selectElements(c("a", "c", "a"), cnames) selectElements(c(1, 3, 1), cnames) # If you don't want to select any of them selectElements(NULL, cnames)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.