How can I retain the (additional) white space of a character column in a flextable? The code sequence
flextable(data.frame("temp" = c("Lore ips",
"dol sit")))
generates the following image:
Note how the "ips" and "sit" subtexts would be aligned in the data.frame
but are not aligned in the flextable.
White spaces are indeed collapsed in HTML output. You can use a tab instead:
flextable(data.frame("temp" = c("Lore ips", "dol\tsit")))
Or you can add extra css instruction (for the HTML output):
set_flextable_defaults(extra_css = ".tabwid{white-space: break-spaces;}")
flextable(data.frame("temp" = c("Lore ips", "dol sit")))