Reputation: 331
I've created a map with leafletR and I'd like the popup in addCircles
to include 2 variables from my data set, but I'd like them each on a new line.
The code I've tried with sprintf
is this, which works except it all shows on a single line. How can I split this across 2 lines?
popup= sprintf("Store: %s \n TY Sales: £%0.0f", Stores$Store, Stores$X2016)
Upvotes: 0
Views: 707
Reputation: 86
You can use HTML formatting along with sprintf to insert italics, line breaks, and links.
library(htmltools)
labels <- mapply(function(x, y, z, a) {
HTML(sprintf("%s<br><em>%s</em><br>%s<br><a href=%s>link</a>", htmlEscape(x), htmlEscape(y), htmlEscape(z), htmlEscape(a)))},
data$var1, data$var2, data$var3, data$var4, SIMPLIFY = FALSE)
Upvotes: 1