I’m writing error handling steps for an R function that fails to find the right match to a query, so presents users with a list of options. I have the output of potential matches in a list, and I’d like the warning to format this as a numbered list:
'multiple matches for query "Tom", select which one you want:'
[1] Tom Bombadil
[2] Tom Overhill
[3] Justanother Tom
Unfortunately, warning and message seem to like removing linebreaks. For instance, if I have:
opts <- list("Tom Bombadil", "Tom Overhill", "Justanother Tom")
The command
warning(opts)
prints:
Warning message:
Tom BombadilTom OverhillJustanother Tom
How do I get this into the format I’d like from above (ideally with numbers so I can capture the number choice from readLines)
Thanks!
What about this: