Let’s say I have this function:
f <- function(input){
name <- "hello_"
}
I want to be able to use
f(world)
and have name
be renamed to "hello_world"
.
Important is that I don’t want the input to be a string. So the solution should not involve f("world")
.
>Solution :
Use substitute
like this:
f <- function(input) paste0("hello_", substitute(input))
f(world)
## [1] "hello_world"