【问题标题】:Replace underscore with white space in column names of datatable将数据表列名中的下划线替换为空格
【发布时间】:2022-08-12 21:00:39
【问题描述】:

如何用空格替换数据表列名中的下划线?

library(DT)

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

dt::datatable(f)

    标签: r dt


    【解决方案1】:

    您可以使用来自stringrstr_replace

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-12
      • 2020-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-14
      相关资源
      最近更新 更多