我想在列
中的每个字符串之前和之后删除\ r \ n \ r \ ndf = data.frame(names = c("\r\n\r\n17-Hydroxyprogesterone\r\n\r\n", "\r\n\r\n5-HIAA\r\n\r\n", "\r\n\r\nAcetaminophen\r\n\r\n", "\r\n\r\nAcetylcholine Receptor (AChR) Antibody\r\n\r\n"))
预期输出
names
n17-Hydroxyprogesterone
5-HIAA
Acetaminophen
Acetylcholine Receptor (AChR) Antibody
答案 0 :(得分:1)
使用Base R尝试:
df$name <- gsub(“r\\n\\r\\n”, “”, df$name)
使用dplyr
:
df <- df %>%
mutate(name = gsub(“r\\n\\r\\n”, “”, name)