Just wonder if there is any shortcut in R to add the quotation mark to a vector? So it will be like c(lemon, orange, apple) to c("lemon", "orange", "apple") without manually going to each item to change it since sometimes many items can be in a vector. Thanks.
You can try
as.character(quote(c(lemon, orange, apple)))[-1]
Or another option as suggested by @MrFlick in the comments
as.character(expression(lemon, orange, apple))
v = c("lemon", "orange", "apple")
v = paste0('"', v, '"')
# use cat in this case to see what's "really" there
# print will show the quotes escaped with backslashes
cat(v)
## "lemon" "orange" "apple"
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