Skip to content

Instantly share code, notes, and snippets.

@ColinFay
Last active January 18, 2018 05:22
Show Gist options
  • Save ColinFay/46f81d813c902043781f7330de745319 to your computer and use it in GitHub Desktop.
Save ColinFay/46f81d813c902043781f7330de745319 to your computer and use it in GitHub Desktop.
# Classic character vector
paste0("as",".","numeric")
# getting a function
get(paste0("as",".","numeric"))
# getting and running a function
get(paste0("as",".","numeric"))("1")
# With objects
x <- "as"
y <- "is"
get(paste0(x,".","numeric"))("1")
get(paste0(y,".","numeric"))("1")
# Another function
action_type_what <- function(action, type, what){
get(paste0(action,".",type))(what)
}
action_type_what("is", "numeric", "1")
action_type_what("as", "numeric", "1")
action_type_what("is", "character", 1)
action_type_what("as", "character", 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment