| select | R Documentation |
Interactive menu for selecting a single item from a list. Uses arrow keys (or j/k) to navigate and Enter to select.
select(
choices,
prompt = "Select an item:",
selected = NULL,
return_index = FALSE,
max_visible = 10L
)
choices |
Character vector of choices to display |
prompt |
Prompt message to display |
selected |
Pre-selected item (index or value) |
return_index |
Return index instead of value (default: FALSE) |
max_visible |
Maximum number of items to display at once (default: 10). Set to NULL to show all items. |
Selected item as character or index, or NULL if cancelled
if (interactive()) {
choice <- select(c("Yes", "No", "Maybe"))
index <- select(c("First", "Second", "Third"), return_index = TRUE)
# With scrolling for long lists
choice <- select(1:100, max_visible = 10)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.