I am trying to create a function that can pass two arguments to make up a new concatenated string.
I expect that this function
fun1(apple, orange)
to produce:
apple and orange
However, for some reason, when I run this function, it cant find and pass the arguments.
fun1 <- function(first, second){
first_str <- as.character(first)
second_str <- as.character(second)
sentence <- str_c(orig_str ," and ", dest_str)
return(sentence)
Error in fun1(apple, orange) : object 'apple' not found
This would work if I pass a string right away,
fun1("apple", "orange")
[1] apple and orange
My intention is to make users fill the arguments on an input bar, and have the function convert it to the character. Thus I would not want to require the users to use "" and pass arguments in the string format. What would be a good alternative?