I have a sample dataframe with values:
data <- structure(list(A = c("Date)", "Values"), B = c("2023-04-03", "Heat Capacity\nSpecific Heat Capacity\nHeat Index" )), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame" ))
Here the 2nd row of last column extends to the right. I want the each values to be in new line without adding new rows.
My desired output:
The above table is created using gt()
:
library(gt)
data %>%
mutate(b = str_replace_all(b, "\n", "<br>")) %>%
gt() %>%
fmt_markdown(columns = TRUE)
But this is not useful as my final desired output I want is in xlsx file and using gt()
wouldn't work.
Is it possible to do anything with dplyr
and stringr
to achieve this similar result