I have a database in a myfile.csv file with long names. This is its structure:
basin,lat,lon,res.density,rel.area
Ventura-Santa Barbara,34.25,-119.4,27.3,40
Central (and very-very long) Marakaibo,9,-71,74.4,14.3
One use of this is to plot the names in the "basin" fields as labels, for example, using leaflet package on a worldmap. Here is the code:
basins<-read.csv("myfile.csv")
library("leaflet")
library("htmltools")
library("leaflet.minicharts")
leaflet(data = basins) %>%
addTiles() %>%
addCircleMarkers(~lon, ~lat ,radius=0,label=~htmlEscape(basin),labelOptions=labelOptions(noHide=T,textOnly=TRUE,direction="bottom", offset=c(0,5)))
However, all long names are on single lines. How it is possible to design the database in .csv and then parse it to the plotting command, so that long names are broken into two lines? Setting the names in database as "Ventura-\n Santa Barbara" does not help, since these "\n" symbols are not parsed and appear as text on the labels.