I am currently writing a function that accepts only certain inputs (in the example, only "a" and "b"). For all other inputs, the function will return an error.
test <- function(x) { allowedX <- c("a","b") if(x %in% allowedX) print("Good choice!") else stop("wrong input!") }
To help users of this function, I would like to provide the permitted values ββfor x (stored in the permitted X) using the tab completion function in R and replace the default file name, which is usually used after the quote. Therefore, pressing TAB should give something like:
test(x="<TAB> ab
However, so far I have not been able to find a solution on how to map the allowX vector to the end of the tab in R. Can someone tell me how to do this?
Thanks in advance!
source share