How to add line break or newline of space in dataframe column in rmarkdown pdf?

I'm using r-markdown to generate pdf. i want to add a line break or newline to a column in a dataframe where ever the space is there.

C1       C2    ID
-----------------
22.6    a-b    a
23.5    ba-cd  b
24     c-d     c
25.3    d-e    d

i want output like

C1     ID
-----------
22.6   a
a-b

23.5   b
ba-cd

my code

df$C1<- with(df, paste0(C1,'\n', C2))

df$C2<-NULL

kbl(df,booktabs = T,longtable = T,align = c("c", "c", "c", "c")) %>%
kable_styling(latex_options = c("repeat_header"),bootstrap_options = "bordered",font_size = 7,full_width = F)%>%
  column_spec(1, width = "8cm")%>%
  column_spec(2:4, width = "2.25cm")

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.