0

I am getting an error saying:

**ERROR: C:\Users\user\Desktop\practice_4/app.R:59:32: unexpected INCOMPLETE_STRING
58:     tabItem(tabName = "signup",
59:             textInput("name",  "
                                   ^**

I was able to run the same code successfully when I was not using shinyDashboard library. From what I've found so far, it looks like a sys.locale() error (someone asked similar question: "unexpected INCOMPLETE_STRING" error when printing Chinese word).

When I run sessionInfo() I get the following result:

R version 3.1.1 (2014-07-10)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Korean_Korea.949  LC_CTYPE=Korean_Korea.949    LC_MONETARY=Korean_Korea.949
[4] LC_NUMERIC=C                 LC_TIME=Korean_Korea.949    

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

other attached packages:
[1] ggplot2_2.1.0        googleVis_0.5.10     xtable_1.8-2         shinyjs_0.6         
[5] shinydashboard_0.5.1 shiny_0.13.2        

loaded via a namespace (and not attached):
 [1] colorspace_1.2-6 digest_0.6.9     DT_0.1           grid_3.1.1       gtable_0.1.2     htmltools_0.3.5 
 [7] htmlwidgets_0.6  httpuv_1.3.3     jsonlite_0.9.19  magrittr_1.5     mime_0.3         miniUI_0.1.1    
[13] munsell_0.4.2    plyr_1.8.3       R6_2.1.2         Rcpp_0.11.5      RJSONIO_1.3-0    scales_0.4.0    
[19] tools_3.1.1      yaml_2.1.13     

I tried setting sys.locale as follows with no success:

Sys.setlocale("LC_TIME", "ko_KR.UTF-8")
Sys.setlocale("LC_CTYPE", "ko_KR.UTF-8")
Sys.setlocale("LC_COLLATE", "ko_KR.UTF-8")
Sys.setlocale("LC_MONETARY", "ko_KR.UTF-8")
Sys.setlocale("LC_MESSAGES", "ko_KR.UTF-8")

Here is my code for ui.R:

body<- dashboardBody(

  actionButton("showSidebar", "Show sidebar"),
  actionButton("hideSidebar", "Hide sidebar"),

  tabItems(
tabItem(tabName = "leaderboard",
        h2="Leaderboard content goes here.",
        dataTableOutput("content")),
tabItem(tabName = "stats",
        h2="stats goes here.",
        fluidRow(
          column(5,
                 hr(),
                 verbatimTextOutput("summa1")),
          column(4,
                 hr(),
                 uiOutput("summa2")),
          column(4,
                 hr(),
                 uiOutput("summa3")))),
tabItem(tabName = "signup",
        textInput("name",  "이름"), # this is where error occurs
        selectInput("college", "대학",choices = list("간호대학", "경영대학",
                                   "공과대학", "농업생명과학대학",
                                   "미술대학", "법과대학",
                                   "사범대학", "사회과학대학",
                                   "수의과대학", "생활과학대학",
                                   "약학대학", "음악대학",
                                   "인문대학", "의과대학",
                                   "자연과학대학", "기타"),
                    selected = 1)))
Community
  • 1
  • 1
Oleole
  • 381
  • 4
  • 21
  • 1
    That's a very old version of R. The latest version is 3.3.3. I would expect the same error to appear if I tried even a simple assignment, eg `x = "이름"`. I don't get this error on 3.3.2 though – Panagiotis Kanavos Mar 07 '17 at 14:53
  • BTW, no repro for `print("寛")` on 3.3.2. Looks like this is an R bug that was fixed in a later version – Panagiotis Kanavos Mar 07 '17 at 14:56
  • @PanagiotisKanavos That entirely depends on your operating system and locale. For example, try setting `LANG` to a non-multibyte encoding. – Konrad Rudolph Mar 07 '17 at 14:56
  • @KonradRudolph not with Unicode, it shouldn't. Several R packages do have issues though. Some treat ANSI and UTF8 strings the same and store them in `char` arrays, resulting in strange behaviour that can be fixed by changing the locale. Some do so inconsistently, usinb wide buffers (wchar) in some functions , narrow (char) in others. And some do the right thing and treat Unicode as Unicode, and allow you to pass the codepage you want for ASCII text as a parameter – Panagiotis Kanavos Mar 07 '17 at 15:00
  • @PanagiotisKanavos If you set a non-Unicode locale, R cannot handle Unicode encodings on Unix (I just tried it to be sure on macOS with R 3.3.2). Furthermore, [Unicode in R on Windows is broken](http://stackoverflow.com/a/5588488/1968). – Konrad Rudolph Mar 07 '17 at 15:05
  • @KonradRudolph Unicode in R on Windows isn't broken, since Windows uses Unicode inherently. It's R itself (or the packages) that hasve issues, precisely because they use `char*` buffers instead of `wchar*`. And BTW - no repro on 3.1.2 on Windows either `R version 3.1.2 (2014-10-31) Platform: x86_64-w64-mingw32/x64 (64-bit) locale: [1] LC_COLLATE=Greek_Greece.1253 ...`. I'll have to check for a 32-bit version too – Panagiotis Kanavos Mar 07 '17 at 15:07
  • @OleOle how did you enter the values? Did you type them by hand or is this a script file? *Did* you save the file as UTF8/UTF16? If you save it as ASCII (ie non-Unicode) with the wrong codepage the charactes may get converted. If you try to load an ASCII file on a computer that has a different locale than the original, you'll also run into conversion problems – Panagiotis Kanavos Mar 07 '17 at 15:11
  • @PanagiotisKanavos Right, it’s *Unicode in R* that’s broken on Windows, as I wrote (Windows itself is handling Unicode kinda OK but their fixed-width encoding is a problem in itself, as it fundamentally only handles subsets of Unicode correctly; [read the *UTF-8 everywhere* manifesto](http://utf8everywhere.org/) for more information). But it’s not (primarily) packages — it is R itself that has issues (see the linked answer and my comment there). This doesn’t mean that nothing related to Unicode works. But it does mean that *some things* don’t work. – Konrad Rudolph Mar 07 '17 at 15:11
  • @OleOle I'm using RStudio 1.0.136 to test the snippets btw – Panagiotis Kanavos Mar 07 '17 at 15:12
  • No repro on 3.1.2 i386 either. – Panagiotis Kanavos Mar 07 '17 at 15:12
  • @KonradRudolph that link is from 2011, R itself has made a lot of improvements since then. I've only encountered Unicode issues with packages. Unfortunatelly, not all package maintainers understand that eg, a German or Greek analyst may have to handle English, German *and* Cyrillic text data in the same script. – Panagiotis Kanavos Mar 07 '17 at 15:17
  • @KonradRudolph real world examples - beer bottle sales data for a large Polish glass factory, or bed pillows from Greek company that sells to Albania and Bulgaria. – Panagiotis Kanavos Mar 07 '17 at 15:18
  • @PanagiotisKanavos The link may be from 2011 but the problem is definitely still present in much more recent versions. Admittedly I haven’t checked with R 3.3.x because I’m not on Windows but members of the core R development team have said on the r-devel mailing list that the problem is hard/impossible to fix (citing the “fact” that Windows doesn’t understand Unicode which, uh, it does). – Konrad Rudolph Mar 07 '17 at 15:23
  • @KonradRudolph hard, only if they were careless with the type declarations. [C11](https://en.wikipedia.org/wiki/C11_(C_standard_revision)) added UTF-16 and -32 character types (char16_t, char32_t) so R's codebase will have to evolve to follow the standard. – Panagiotis Kanavos Mar 07 '17 at 15:32
  • @PanagiotisKanavos I tried running the script on R version 3.3.2 but it gives an error saying : **Warning in checkEncoding(file) : The input file C:\Users\user\Desktop\practice_4/app.R does not seem to be encoded in UTF8 Warning: invalid input found on input connection 'C:\Users\user\Desktop\practice_4/app.R' Error in parse(file, keep.source = FALSE, srcfile = src, encoding = enc) : C:\Users\user\Desktop\practice_4/app.R:54:32: unexpected INCOMPLETE_STRING** – Oleole Mar 07 '17 at 15:35
  • **53: tabItem(tabName = "signup", 54: textInput("name", " ^ Warning: Error in sourceUTF8: Error sourcing C:\Users\user\AppData\Local\Temp\RtmpGYAjqI\file2d1ce6e32f4 Stack trace (innermost first): 1: shiny::runApp Error : Error sourcing C:\Users\user\AppData\Local\Temp\RtmpGYAjqI\file2d1ce6e32f4** – Oleole Mar 07 '17 at 15:36
  • @KonradRudolph but not yet it seems? Searching for `char16_t` at https://github.com/wch/r-source/search?utf8=%E2%9C%93&q=wchar returns nothing, `char32_t` a comment and `wchar` is used mainly for Windows. [This](https://github.com/wch/r-source/blob/57a820f2c530c76fb611db0fbce07177093e00da/src/main/platform.c#L573) shows that `wchar` is used on Windows, ASCII on non-Windows OSs! – Panagiotis Kanavos Mar 07 '17 at 15:38
  • @Oleole this probably means that the *file* was saved as ASCII. Were you able to just copy and paste `print("寛")` ? You can convert your file to Unicode from RStudio's `Save With Encoding` option or even Notepad – Panagiotis Kanavos Mar 07 '17 at 15:39
  • Also, print ("이름") works fine in R version 3.1.1 as well. It worked fine when I was NOT using dashboard functions from shinyDashboard library and instead was using normal shiny functions such as fluidPage. – Oleole Mar 07 '17 at 15:39
  • 1
    @Oleole the error comes from R itself, not the function. Perhaps RStudio itself failed to open the file properly? I just tried to open a UTF8 script but RStudio loaded it as ASCII. I had to `Reopen with encoding` to load the Korean and Chinese characters – Panagiotis Kanavos Mar 07 '17 at 15:44
  • @PanagiotisKanavos I tried reopening with encoding, set UTF8, and it works now! Thanks so much for your help :) – Oleole Mar 07 '17 at 16:04
  • @PanagiotisKanavos I urge you to read the *UTF-8 everywhere* manifesto. You don’t need `wchar_t`/`char16_t`/`char32_t`, in fact it would be counter-productive. The `char*` data type is entirely sufficient (although a dedicated character type would of course be welcome). And it goes without saying that `char*` has nothing to do with ASCII. It’s simply an encoding agnostic byte buffer. – Konrad Rudolph Mar 07 '17 at 16:11

1 Answers1

0

I use Japanese but during importing of the file I source it with encoding for all imports

source("constants.R",encoding = "UTF-8")

and saved the main file which I am going to run with utf-8 endcoding with the file>save_with_encoding

vishal
  • 855
  • 1
  • 8
  • 16