I have a string in R:
mystring <- "2 and 4"
I want to use gsub to put " hours" after every occurance of a number, so that the string looks like this:
"2 hours and 4 hours"
I have tried this, which matches the number, but I want the number returned in the output:
gsub("\\d{1}", "\\d{1} hours", mystring)
[1] "d{1} hours and d{1} hours"
How do I include the original number in the output?