Suppose you have a vector of numbers vec <- (1,3,4,7) that needs to be combined with the symbols (“#”,”?”)

Category: R LanguageSuppose you have a vector of numbers vec <- (1,3,4,7) that needs to be combined with the symbols (“#”,”?”)
Editor">Editor Staff asked 2 years ago

Suppose you have a vector of numbers vec <- (1,3,4,7) that needs to be combined with the
symbols (“#”,”?”) consecutively such that we obtain the output 1-#, 3-?, 4-#, 7-? How will you
proceed with this?

2 Answers
Editor">Editor Staff answered 2 years ago

Ans. We will use the paste() function as follows –
paste(vec,c(“#”,”?”),sep = “-“)

Editor">Editor Staff answered 2 years ago

Ans. We will use the paste() function as follows –
paste(vec,c(“#”,”?”),sep = “-“)