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

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -