Replace underscore with white space in column names of datatable

Viewed 27

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)
1 Answers

You can use str_replace from stringr

names(f) <- stringr::str_replace(names(f), "_", " ")
Related