cjk - Removing "\037" from strings in R -
i preparing dataset contains cjk characters r , through tidyverse. during process, found character elements has \037 @ end.
# tibble: 99 × 2 prefecture n <chr> <int> 1 \037 1 2 北海道\037 1 3 北海道 13 4 北海道 4 ... ... ... i have tried remove them line below:
library(stringr) out.file %>% mutate( prefecture = str_replace_all(out.file$prefecture, "\\\\037", "") ) the str_replace_all remove \037s when being tested on string. when applying mutate on entire column, however, lines above still gives same results in first code chunk in post.
what efficient way remove them strings?
update solution
require(stringi) out.file %>% mutate(prefecture = stri_escape_unicode(prefecture), prefecture = str_replace_all(prefecture, "\037", ""), prefecture = stri_unescape_unicode(prefecture)) this way able resolve issue successfully.
Comments
Post a Comment