How to use UTF-8 characters in dygraph name in R

Using Rstudio [Windows8], when I use the dygraph function to build a time series, I have a problem when trying to use UTF-8 characters in the main header.

library(dygraphs)
dygraph(AirPassengers, main = "Título")

This leads to the title: "T? Tulo"

I tried converting "Título" to utf-8, but it does not work.

+4
source share
2 answers

You need to make sure that your language settings support the character you want to use, and that the file is saved with the correct encoding. Saving as UTF-8 worked for me.

I was able to reproduce your situation in Windows 7 and tried a bunch of things. Nested in Rmarkdown, here is a minimal working example.

```{r}
Sys.setlocale("LC_ALL","German")
#note that windows locale names are different from unix & mac, usually
#the name of nationality works here.
#also works with "Faroese", "Hungarian", and others who have this letter.
#the locale has to be set in a preceding block to take effect.
```

```{r}
Encoding("Título")
library(dygraphs)
dygraph(AirPassengers, main = "Título")
```

, , Encoding(). , , , "Título" , , , javascript dygraph. UTF-8 <U+00ED>, javascript, , . utf-8, @Michele, .

, , html/javascript, . , , title . - Rstudio "Viewer", javascript, , .

+1

enc2utf8.

dygraph(AirPassengers, main = enc2utf8("Título"))
+2

All Articles