I need a function that will take input as a character string (BLANK) and print out the following:
"Hello BLANK World"
i.e., world("seven") prints out "Hello seven World"
I'm very confused on how to work with character strings in R.
You want the function paste
world <- function(x) paste("Hello", x, "World")
Or...
x <- "seven"
sprintf("Hello %s World", x)
In other words no need for a world function as that's what sprintf does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With