Home > Software engineering >  Replace underscore with white space in column names of datatable
Replace underscore with white space in column names of datatable

Time:07-26

How can I replace underscore in column names of datatable with white space?

library(DT)

D_d<-c("34","43","43")
d_g<-c("45","54","54")
f<-data.frame(D_d,d_g)

dt::datatable(f

CodePudding user response:

You can use str_replace from stringr

names(f) <- stringr::str_replace(names(f), "_", " ")
  •  Tags:  
  • r dt
  • Related