Within my shiny app, I am having my users select n number of attributes to plot within my splom()
call, which essentially follows these steps:
lplot <- splom(data_subset)
.However, since the panels within splom()
are being labeled based on the attribute name (which is reactive, so I can't label ahead of time) and the names are very long you can't read them.
Does anyone know if there is a way to wrap text within the splom panel outputs? The wrapping would be done on the attribute reactive value, so it wouldn't be done on a string.
This is what my output looks like:
After subsetting in step 3, you can manipulate the names of the data subset to wrap appropriately.
## Subset the data in whatever way shiny does (here's a reproducible example)
irisSub <- subset(iris, select = grepl("Width", names(iris)))
Then
Replace "word" separators with spaces. In your example, you probably just need "_"
names(irisSub) <- gsub("\\.|_", " ", names(irisSub))
Wrap these strings at a fairly narrow width. You might have to experiment with other widths here.
wrapList <- strwrap(names(irisSub), width = 10, simplify = FALSE)
Paste these strings back together with a linebreak (\n
) in between and assign them to names of data subset
names(irisSub) <- vapply(wrapList, paste, collapse = "\n", FUN.VALUE = character(1))
splom
should respect the line breaks
splom(irisSub)