【问题标题】:Multiple replacement in entire data frame in RR中整个数据帧的多次替换
【发布时间】:2021-01-14 13:56:14
【问题描述】:

我有一个 12 列的数据框,必须进行多次替换。这就是我正在做的每次更换。有没有更好的方法来进行多次替换?

clean_df2<- map_df(clean_df1, ~ gsub("None", "-", .x))

【问题讨论】:

  • 试试clean_df1[clean_df1=='None']&lt;-'-'
  • clean_df2&lt;-clean_df1clean_df2[clean_df2=='None']&lt;-'-'

标签: r gsub


【解决方案1】:

这也可以:

library(dplyr)
#Code
clean_df2 <- clean_df1 %>% mutate(across(everything(),~gsub("None", "-", .)))

【讨论】:

    猜你喜欢
    • 2021-06-27
    • 1970-01-01
    • 2022-09-23
    • 1970-01-01
    • 2020-05-26
    • 1970-01-01
    • 1970-01-01
    • 2019-01-07
    • 1970-01-01
    相关资源
    最近更新 更多