How to use accent in shiny server?

2,769 views
Skip to first unread message

Erica Castilho Rodrigues

unread,
Aug 26, 2013, 3:50:13 PM8/26/13
to shiny-...@googlegroups.com
Hy everyone,

I am trying hard to find a solution to a problem, but I could not...
I am trying to publish a tabe wich has an accent like "República", it works fine in my computer.. But when I try to publish it using the Shiny Server it is not possible.
Does anyone know how to solve it?

Thanks a lot

Erica

Grégoire Vincke

unread,
Nov 22, 2013, 9:42:41 AM11/22/13
to shiny-...@googlegroups.com
Hi, I have the same problem with french accented letters inside the plot area.

My computer succed to render them inside a plot (text() function) but my remote shiny-server do not.

Both my computer and remote server are running Linux, both have fr_FR.UTF-8 as locale in system and in R
Both are running R 3.0.2

Do you have any idea ?
Is there a library beside R to render plot to web images that coul use an other locale ?

Gregoire

Stéphane Laurent

unread,
Nov 22, 2013, 10:58:13 AM11/22/13
to shiny-...@googlegroups.com
Have you tried
enc2utf8(text)
or 
Encoding(text) <- "UTF-8"
?

Grégoire Vincke

unread,
Nov 22, 2013, 4:09:11 PM11/22/13
to shiny-...@googlegroups.com
No because the code work very well locally, and work very well on http://spark.rstudio.com/
There is only on our own instance of shiny-server that this problem occurs.
That's why i'm searching what can generate this on the server's side more on the app source code side.

I want to know what can explain that through Shiny as local app it work, but not through shiny-server.

Gregoire

Grégoire Vincke

unread,
Nov 22, 2013, 4:30:06 PM11/22/13
to shiny-...@googlegroups.com
The code is here : https://github.com/rbagd/inflation
The hosting on spark is here : http://spark.rstudio.com/rytis/inflation/
The hosting on the server i try to configure is here : http://sites.uclouvain.be/selt/shiny/inflation/

As you can notice, the accents are not rendered in the legend of the plot, and the table in the second tab is not rendered neither due to accents.
To have the code running, i had to take accents out of variable names at line 41 of server.R :
poids.table$Catégorie <- as.character(poids.table$Catégorie)
became
poids.table$Categorie <- as.character(poids.table$Categorie)

but the original line 41 works quite well locally and on sparks...
Locale of both my desktop and my shiny-server are fr_FR.UTF-8, and all files are UTF-8 encoded, so I don't understand why this occurs...

Stéphane Laurent

unread,
Nov 22, 2013, 5:44:36 PM11/22/13
to shiny-...@googlegroups.com
Au boulot je développe mes applis Shiny sous Windows et quand je les transfère sur le serveur Linux je dois à nouveau les ré-enregistrer en UTF-8. 

Sorry to speak French, I am sick of speaking English.


Joe Cheng

unread,
Nov 22, 2013, 5:52:45 PM11/22/13
to gregoir...@gmail.com, shiny-...@googlegroups.com
Hmmm, that's very mysterious. It does seem to be an encoding problem, but I don't see anything wrong with your code and like you, can't repro it here or on spark.

What version of Shiny is installed on sites.uclouvain.be? Be sure you are checking the version that's available to the shiny user, not your usual user. If you have sudo you can do this:

  sudo su - shiny -c "R -e 'packageVersion(\"shiny\")'"

Can you also do "md5sum *" in the app directory on your server, to ensure some subtle difference in code has not arisen?


On Fri, Nov 22, 2013 at 2:44 PM, Stéphane Laurent <lauren...@yahoo.fr> wrote:
Au boulot je développe mes applis Shiny sous Windows et quand je les transfère sur le serveur Linux je dois à nouveau les ré-enregistrer en UTF-8. 

Sorry to speak French, I am sick of speaking English.


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Grégoire Vincke

unread,
Nov 23, 2013, 3:06:02 PM11/23/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
I have shiny 0.7.0 on R 0.3.2 on sites.uclouvain.be (CentOS) and shiny 0.8.0 on R 0.3.2 on my local computer (Fedora).
A "file -bi server.R" gives me text/x-java; charset=utf-8
Locales of system and R are on both computers fr_FR.UTF-8

Grégoire Vincke

unread,
Nov 23, 2013, 3:13:00 PM11/23/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Sorry, sent to quickly. How can I check the shiny-server version, or node.js one's?
Is there a different process involved in plot ganaration between shiny as a R library and shiny-server as a service ?

Thanks for advise.

Gregoire

Grégoire Vincke

unread,
Nov 25, 2013, 4:42:46 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Hi,

I updated Shiny from 0.7.0 to 0.8.0 on sites.uclouvain.be/selt/shiny/ and I set en_US.UTF-8 as main locale, verified that this UTF-8 is used by the Shiny user R instance. Then I stopped then started the shiny-server but nothing changed. Still have problem since a accentuated letter is inside code or datas.
This drives me crazy.

Gregoire

Stéphane Laurent

unread,
Nov 25, 2013, 5:54:04 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Moi aussi j'ai failli finir dingue avec des problèmes d'encodage. Comment encodes-tu le fichier en UTF8 ? Le seul moyen que je connaisse qui marche, c'est d'enregistrer le fichier en UTF8 dans le serveur Linux avec RStudio.

Grégoire Vincke

unread,
Nov 25, 2013, 6:44:53 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Laurent, my files are created under linux (my desktop running FEDORA 18 using UTF-8 as native encoding system), and the uploaded to the CentOS server, also using UTF-8. A check of the encoding of the files says that they are un UTF-8 so I don't think that the problem comes from the encoding of the files, but more on the different process called by shiny-server.
Most of R users are using Debian/Ubuntu flavors to run linux, and I think that maybe the problem is comming from I use CentOS, who do not have lots of R stuffs in it's packaging system.

I'm still searching...

If anybody have ideas...

Gregoire

Grégoire Vincke

unread,
Nov 25, 2013, 7:11:16 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Stephane, in an other discussion in this mailing-list you mention https://gist.github.com/stla/7144955

If I run it locally on my laptop i have :
Version: R version 3.0.2 (2013-09-25)
- Platform: x86_64-redhat-linux-gnu
- Locale: LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C

But if I run it on my server : http://sites.uclouvain.be/selt/shiny/session/
I have :
Version: R version 3.0.2 (2013-09-25)
- Platform: x86_64-redhat-linux-gnu
- Locale: C

But if i go on my server by SSH, run R (same user of the one specified in the shiny-server configuration), and then ask sessionInfo() i receive :
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-redhat-linux-gnu (64-bit)
locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C             
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8   
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8  
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                
 [9] LC_ADDRESS=C               LC_TELEPHONE=C           
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C      

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

Do you have explanaition for the "locale : C" instead of the "Locale: LC_CTYPE=fr_FR.UTF-8;LC_NUMERIC=C;LC_TIME=fr_FR.UTF-8;LC_COLLATE=fr_FR.UTF-8;LC_MONETARY=fr_FR.UTF-8;LC_MESSAGES=fr_FR.UTF-8;LC_PAPER=fr_FR.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=fr_FR.UTF-8;LC_IDENTIFICATION=C " ??

This looks definitiveley strange...

Gregoire

Grégoire Vincke

unread,
Nov 25, 2013, 8:52:26 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Hi Guys,

Problem (partially) solved !

Thanks to shiny app of Laurent ( https://gist.github.com/stla/7144955 ) I realised that sessionInfo() in R, sessionInfo() inside a shiny app called locally, and sessionInfo() inside a shiny App delivered through shiny-server do NOT give the same answer regarding to locale ! R and local shiny are OK (give UTF-8) but shiny server give the single value of "C"...

After reading this : http://stat.ethz.ch/R-manual/R-devel/library/base/html/locales.html  i added to the top of the server.R file this instruction :

Sys.setlocale("LC_ALL", "fr_FR.UTF-8")

and it works (partially) normally, at least ! I say partially because if I stop/start my shiny-server the problem of the accentued variable at lines 40 and 41 remains until I take the accent over. BUT, if I call the app once in it(s corrected way, and then reput the accents in the var names at lines 40 and 41 of server.r, it work perfectly... So it acted like the Sys.setlocale("LC_ALL", "fr_FR.UTF-8") was not taking into account since the code is not readed once fully, and then it's ok.

I tried before Sys.setenv(LANG="fr_FR.UTF-8") and options(encoding="UTF-8") but without success.

So now the question is : how can I do to set this definitively to all the apps running on my shiny-server without beeing obliged to add this at the top of all apps ?

Thanks for advises.

Grégoire

Grégoire Vincke

unread,
Nov 25, 2013, 9:04:53 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
And the main question is "Why shiny-server DO NOT consider the default locale of the system ???"
Is it possible that the install process under CentOS is not the same than in Debian/Ubuntu ?

Do other CentOS users running shiny-server with app not in english have the same problem ???

By the way, thanks to Laurent and his session app : https://gist.github.com/stla/7144955 which has put my attention on sessionInfo() inside and outside of shiny-server.

Gregoire

Stéphane Laurent

unread,
Nov 25, 2013, 9:48:33 AM11/25/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Glad to know that this app has helped someone. 
Just call me Stéphane next time ;-)

Stéphane Laurent

unread,
Dec 5, 2013, 10:48:45 AM12/5/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Actually I get exactly as you : 


Fereshteh Karimeddini

unread,
Dec 5, 2013, 5:36:05 PM12/5/13
to shiny-...@googlegroups.com, gregoir...@gmail.com
Gregoire,

It seemed that your issue was partially solved, but you had follow up questions. Sorry didn't respond to that sooner.

If you are running on CentOS, you can check the following for your system-wide locale setting:

/etc/sysconfig/i18n

This is most likely where your Shiny Server is taking the locale setting from. If the LANG setting in this file is not a variation of UTF-8, you can change this and restart your server. Of course this way you will change the locale globally. 

You can also overwrite the global locale in user's environment. For this:
1- If you are running Shiny apps as "shiny" user, create a file called .Renviron in /home/shiny directory with this content: (notice the dot in the filename)

   LANG=fr_FR.UTF-8

2- If you are running Shiny apps as other users (with "user_apps" option), create the same file in that user's home directory (/home/user).

In both cases restart Shiny Server, and access your applications.

Hope this helps in resolving your issue, or answering your questions. Let us know how it goes.

Best,
Fereshteh

Stéphane Laurent

unread,
Dec 5, 2013, 5:54:08 PM12/5/13
to shiny-...@googlegroups.com
Thank you Fereshteh. 
As I said I have the same behavior as Grégoire. But we use OpenSuse (Entreprise), not Centos. Can we follow the same suggestions to solve this issue ?


Le jeudi 5 décembre 2013 23:36:05 UTC+1, Fereshteh Karimeddini a écrit :


Fereshteh Karimeddini

unread,
Dec 5, 2013, 6:03:32 PM12/5/13
to shiny-...@googlegroups.com
Stéphane,

I don't have much experience with OpenSuse, but found some info on how to set locale:

https://www.suse.com/documentation/sled10/readme/RELEASE-NOTES.en.html#b554yf7


Regardless of the systemwide setting, when R process starts, it will read the .Renviron variable in the user's home directory. This behavior should be consistent across platforms. Please give that a try.

Fereshteh

y.le...@gmail.com

unread,
Jan 30, 2014, 4:15:47 AM1/30/14
to shiny-...@googlegroups.com
Hi,

I read the discussion concerning encoding for the accents. I tried the different solutions proposed in this forum but my (French) accents do not appear correctly.
I don't know what to write and where (ui, server ?). I am under windows.
My session information:

Version: R version 3.0.2 (2013-09-25)

- Platform: i386-w64-mingw32
- Locale: LC_COLLATE=French_France.1252;LC_CTYPE=French_France.1252;LC_MONETARY=French_France.1252;LC_NUMERIC=C;LC_TIME=French_France.1252 

Packages:

- Base: base, datasets, graphics, grDevices, methods, stats, utils
- Other: data.table (v1.8.10), devtools (v1.4.1), foreign (v0.8-57), googleVis (v0.4.7), knitr (v1.5), lubridate (v1.3.3), maps (v2.3-6), maptools (v0.8-27), markdown (v0.6.4), mondate (v0.10.01.02), polyCub (v0.4-1), rCharts (v0.4.2), Rcpp (v0.10.6), sfsmisc (v1.0-24), shiny (v0.8.0), sp (v1.0-14), surveillance (v1.7-0), xtable (v1.7-1)
- Loaded (not attached): abind (v1.4-0), bitops (v1.0-6), caTools (v1.16), deldir (v0.1-1), digest (v0.6.4), evaluate (v0.5.1), formatR (v0.10), grid (v3.0.2), httpuv (v1.2.1), httr (v0.2), lattice (v0.20-23), MASS (v7.3-29), Matrix (v1.0-14), memoise (v0.1), mgcv (v1.7-26), nlme (v3.1-111), parallel (v3.0.2), plyr (v1.8), polyclip (v1.2-0), RCurl (v1.95-4.1), RJSONIO (v1.0-3), spatstat (v1.35-0), statmod (v1.4.18), stringr (v0.6.2), tensor (v1.5), tools (v3.0.2), whisker (v0.3-2), yaml (v2.1.10)

Session Details

- Working directory: D:/000_Meningo

Thanks a lot for you help!

Yann


Le lundi 26 août 2013 21:50:13 UTC+2, Erica Castilho Rodrigues a écrit :

Stéphane Laurent

unread,
Feb 1, 2014, 7:48:53 AM2/1/14
to shiny-...@googlegroups.com
Have you tried, as Grégoire, to type this in server.R:

y.le...@gmail.com

unread,
Feb 1, 2014, 12:06:11 PM2/1/14
to shiny-...@googlegroups.com
Yes and I have the following warning:

Warning in Sys.setlocale("LC_ALL", "fr_FR.UTF-8") :
  OS reports request to set locale to "fr_FR.UTF-8" cannot be honored

Yihui Xie

unread,
Feb 1, 2014, 12:24:41 PM2/1/14
to y.le...@gmail.com, shiny-discuss
Windows does not have a UTF8 locale.

Regards,
Yihui

y.le...@gmail.com

unread,
Feb 1, 2014, 1:23:12 PM2/1/14
to shiny-...@googlegroups.com, y.le...@gmail.com
Thanks for your answers Stéphane and Yihui but it is still unclear for me if there is a way to use accents in a shiny app using windows ...

Yann
Reply all
Reply to author
Forward
0 new messages