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

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -