У меня есть символьный вектор, содержащий 231 документ (231 строка на один столбец). В начале каждого документа есть фрагмент текста, который я хотел бы удалить из каждого из 231 документа.
Давайте рассмотрим пример, где каждый текст имеет следующее начало: Текст, который я хочу удалить .:
Я пробовал следующие варианты без результатов:
x <- c("Text that I wish to remove. I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out.", "Text that I wish to remove. I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out.", "Text that I wish to remove. I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out.", "Text that I wish to remove. I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out.")
strings <- substr(x, 1, 26)
remove_1 <- x %>% str_replace_all(strings)
remove_2 <- gsub(strings, "", x)
ecb_remove <- str_remove_all(ecb_ready, ecb_strings)
В идеале хотелось бы получить:
[1] "I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out."
[2] "I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out."
[3] "I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out."
[4] "I really want to remove the text but I cannot do it. I hope that stackoverflow will sort it out."
Может ли кто-нибудь мне помочь?
Большое спасибо!