R 列中的字符串操作
考虑data.frame,我们可以这样说:R 列中的字符串操作,r,dplyr,stringr,R,Dplyr,Stringr,考虑data.frame,我们可以这样说: df <- data_frame(id = c(1, 1, 2, 2), n = c("100+", "50+", "30+", "40+")) 必须有一种正确的方法为带有dplyr的列应用str_replace()函数。您需要传递要在其上执行替换的列,然后转义加号 library(dplyr) library(stringr) df %>% mutate(n = str_replace(n, "\\+","")) 完美的谢谢 l
df <- data_frame(id = c(1, 1, 2, 2), n = c("100+", "50+", "30+", "40+"))
必须有一种正确的方法为带有dplyr的列应用
str_replace()
函数。您需要传递要在其上执行替换的列,然后转义加号
library(dplyr)
library(stringr)
df %>%
mutate(n = str_replace(n, "\\+",""))
完美的谢谢
library(dplyr)
library(stringr)
df %>%
mutate(n = str_replace(n, "\\+",""))