如何从R中的文本中删除序列号:
样本数据:
a=data.frame(text=c("1.This can be achieved using xyz method. 2. It consists of various steps. 3. For more details, check this website))
预期结果:
This can be achieved using xyz method. It consists of various steps.
For more details, check this website.
答案 0 :(得分:1)
我们可以在此处尝试使用sub
input <- "1.This can be achieved using xyz method. 2. It consists of various steps. 3. For more details, check this website"
input <- gsub("\\d+\\.\\s*", "", input)
[1] "This can be achieved using xyz method. It consists of various steps. For more details, check this website"
答案 1 :(得分:1)
或者使用stringr
包和str_remove_all
函数
> text <- c("1.This can be achieved using xyz method. 2. It consists of various steps. 3. For more details, check this website")
> stringr::str_remove_all(text, "\\d+\\.\\s?")
[1] "This can be achieved using xyz method. It consists of various steps. For more details, check this website"