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

DWQA QuestionsCategory: R LanguageSuppose you have a vector of numbers vec <- (1,3,4,7) that needs to be combined with the symbols (“#”,”?”)
Editor Staff asked 11 months 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 Staff answered 11 months ago

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

Editor Staff answered 11 months ago

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