아래와 같은 데이터 셋이 있는데 어떻게 '#number'를 제거 할 수 있습니까?
df>
terms year
5;#Remote Production;#10; 2021
53;#=Product-Category:Routing 2021
30;#HDR;#5;#Remote Production 2020
...
다음과 같아야합니다.
df>
terms year
#Remote Production 2021
#Product-Category:Routing 2021
#HDR;#Remote Production 2020
...
감사!
옵션 str_remove
library(stringr)
library(dplyr)
df %>%
mutate(terms = str_c('#', str_remove_all(terms, "^\\d+;#\\=?|#\\d+;")))
-산출
# terms year
#1 #Remote Production; 2021
#2 #Product-Category:Routing 2021
#3 #HDR;#Remote Production 2020
df <- structure(list(terms = c("5;#Remote Production;#10;", "53;#=Product-Category:Routing",
"30;#HDR;#5;#Remote Production"), year = c(2021L, 2021L, 2020L
)), class = "data.frame", row.names = c(NA, -3L))
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다