xlookup | R Documentation |
XLOOKUP
functionWorks like Excel's XLOOKUP
function
xlookup(
x,
lookup_vector,
return_vector = NULL,
warn = TRUE,
ignore_case = TRUE
)
x |
a vector of values you want to match in |
lookup_vector |
the vector to match in – get the index for |
return_vector |
the vector to return from |
warn |
TRUE will list values of |
ignore_case |
TRUE will do a case insensitive match of |
Returns a vector of values with the same length as lookup_vector
.
If a value is not found, then NA is returned.
NA can be mapped to a non-NA value.
ref <- data.frame(
state = c('UT', 'SD', 'FL', NA, 'NY', 'CA'),
category = c(1, 2, 5, 10, 6, 7)
)
xlookup('CA', ref$state, ref$category)
xlookup('KY', ref$state, ref$category)
xlookup(NA, ref$state, ref$category)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.