как убрать серийные номера из строки в R - PullRequest
0 голосов
/ 01 апреля 2019

Как убрать серийный номер из текста в 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.

Ответы [ 2 ]

1 голос
/ 01 апреля 2019

Или с пакетом 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"
1 голос
/ 01 апреля 2019

Мы можем попробовать использовать 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"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...