Error: \uxxxx sequences not supported inside backticks (line 1)*

I am trying to run the following lines of code:

ggplot(data = a, aes(a$District, a$ अनु0जाति एवं अनु0 जनजाति विभाग ))+
geom_line()

system generates the following error:
Error: \uxxxx sequences not supported inside backticks (line 1)

following is the session information:

**> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=Hindi_India.1252 LC_CTYPE=Hindi_India.1252 LC_MONETARY=Hindi_India.1252 LC_NUMERIC=C LC_TIME=Hindi_India.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] skimr_1.0.7 data.table_1.12.6 forcats_0.4.0 stringr_1.4.0 dplyr_0.8.3 purrr_0.3.3 readr_1.3.1 tidyr_1.0.0 tibble_2.1.3
[10] ggplot2_3.2.1 tidyverse_1.2.1 haven_1.1.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.3 highr_0.8 cellranger_1.1.0 pillar_1.4.2 compiler_3.6.1 base64enc_0.1-3 tools_3.6.1 zeallot_0.1.0 digest_0.6.22 lubridate_1.7.4
[11] gtable_0.3.0 jsonlite_1.6 evaluate_0.14 lifecycle_0.1.0 nlme_3.1-140 lattice_0.20-38 pkgconfig_2.0.3 rlang_0.4.1 cli_1.1.0 rstudioapi_0.10
[21] yaml_2.2.0 xfun_0.11 withr_2.1.2 xml2_1.2.2 httr_1.4.1 knitr_1.26 generics_0.0.2 vctrs_0.2.0 hms_0.5.2 grid_3.6.1
[31] tidyselect_0.2.5 glue_1.3.1 R6_2.4.1 readxl_1.3.1 rmarkdown_1.17 modelr_0.1.5 magrittr_1.5 scales_1.0.0 backports_1.1.5 htmltools_0.4.0
[41] rvest_0.3.5 assertthat_0.2.1 colorspace_1.4-1 stringi_1.4.3 lazyeval_0.2.2 munsell_0.5.0 broom_0.5.2 crayon_1.3.4

ggplot(data = a, aes(a$District, a$ अल्पसंख्यक कल्याण विभाग ))+
Error: \uxxxx sequences not supported inside backticks (line 1)**

I can't tell if this is an issue with how this is being rendered on the site, or if it's in your code, but it looks like there are spaces in your variable name. In R, this isn't valid, and, if you do use such a name, it needs to be surrounded in backticks. (See Details re. syntactically valid names here).

See also this issue in the RStudio IDE repository re. Hindi support:

Also the linked community issue, here:

It will help to troubleshoot if you could please turn this into a self-contained reprex (short for reproducible example).

install.packages("reprex")

If you've never heard of a reprex before, you might want to start by reading the tidyverse.org help page. The reprex dos and don'ts are also useful.

There's also a nice FAQ on how to do a minimal reprex for beginners, below:

What to do if you run into clipboard problems

If you run into problems with access to your clipboard, you can specify an outfile for the reprex, and then copy and paste the contents into the forum.

reprex::reprex(input = "fruits_stringdist.R", outfile = "fruits_stringdist.md")

For pointers specific to the community site, check out the reprex FAQ.

2 Likes

Thanks Mara, will read what you have indicated here and post a reprex as well.

Hello Mara, I did a small reprex. However, this has led to some other problem, the above image is generated from reprex. it does not show the backtick error in the reprex output but shows all hindi characters as ?.

Below is the Image from my environment where the error does occur

I wonder why is this happening? Also, in my script the characters do show up in hindi.

I also, want to bring to your attention that if i call for the object in my console, hindi characters show up as U+xxxx but if i call the object through reactable() function then it shows up as it should. Consider the following Picture.

I hope i am not asking any convoluted question that is due to some multiple different problems.

You're so close, but not quite there for the reprex, which is making it really hard to read. When you make the reprex, you can paste the output (which will be on your clipboard) here as text!

2 Likes

Hi Mara, thanks for being patient with me. Following is the output from the clipboard that I Pasted. As I mentioned in my previous comment, this has brought me to a new problem, it does not show the backtick error in the reprex output but shows all hindi characters as ?.

data.frame(PetitionID = c(21321321,231321,546586,666268,63555,33555),
           Complaintreceviedvia = c("Internet", "In Person", "Post", "Internet", "Call Center", "Internet"),
           Department = c("???????? ?????",
                          "???????? ?????",
                          "??????? ??????? ?????",
                          "??? ?????",
                          "??? ?????",
                          "???0???? ??? ???0 ?????? ?????")) -> sam_rep
sam_rep ## if this line is executed the output shows in column 3 (department) as  <U+xxxx> format for entries in Hindi, locale is already set to HIndi
#>   PetitionID Complaintreceviedvia                     Department
#> 1   21321321             Internet                 ???????? ?????
#> 2     231321            In Person                 ???????? ?????
#> 3     546586                 Post          ??????? ??????? ?????
#> 4     666268             Internet                      ??? ?????
#> 5      63555          Call Center                      ??? ?????
#> 6      33555             Internet ???0???? ??? ???0 ?????? ?????

## i want ro pivot the data sam_rep

library(tidyverse)

sam_rep %>% 
  spread(Department, Complaintreceviedvia )-> sam_rep_wide

## The sequence problem

### i Want to use the col that is in Hindi, since it has space, it needs to be inside backticks

sam_rep_wide %>% 
  filter(`??? ?????`== "Internet")  ##this genereates the error that \uxxx not supported inside backtick
#>   PetitionID ??? ????? ??????? ??????? ????? ???????? ?????
#> 1     666268  Internet                  <NA>           <NA>
#>   ???0???? ??? ???0 ?????? ?????
#> 1                           <NA>

Created on 2019-11-25 by the reprex package (v0.3.0)

However, if i run the code without using reprex the backtick error does occur and the hindi characters appear as they should in the script, also appears fine if i call the object via reactable, but is displayed in form of <U+xxx> in console. Below are the two images (sorry for posting these as images but I have to in order to describe what I am facing)

1>

2>

Also, more importantly, i just realised that I follow you on twitter and you and batpig are awesome.

Hi Ayush,

I think what's happening is that reprex is converting everything to UTF-8, which is why it's just awash with ????.

From the screenshots, I see you're getting the Unicode code points (e.g. <U+0928>, which is the code point for न) in the output, too — so, unfortunately, I think this is probably the same problem in the other issue and thread (so, probably an IDE issue, rather than package-specific).

Someone who knows more about character encoding than I do might have a workaround for you.

There's a really friendly intro/explanation of string encoding in R in this post by Kevin Ushey. If you're dealing with different character encodings frequently, it's definitely worth a read:
https://kevinushey.github.io/blog/2018/02/21/string-encoding-and-r/

Glad you enjoy the twitter content :blush: , sorry I can't be of more help on this.

P.S. Here's some info on dealing with character encoding specifically in RStudio:

1 Like

Thanks Mara, I will surely look at the post by Kevin Ushey and the RStudio Character Encoding that you have suggested.

Also, Thank you for directing me towards reprex, it is super fun.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.