如何在R降价交互文档中设置文本编码?

时间:2014-12-22 14:53:16

标签: r text encoding markdown shiny

我在R markdown交互式文档中遇到文本编码问题。

除了工具设置为UTF-8中的全局文本编码外,我没有特定的设置。

我的文档代码以:

开头
---
runtime: shiny
output:
  html_document:
    fig_width: 12
    fig_height: 8
---

```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(comment="", message=FALSE, fig.width=12, fig.height=8,tidy.opts=list(keep.blank.line=TRUE, width.cutoff=80),options(width=90))
```


```{r, eval=FALSE}
library(devtools)
devtools::install_github("rstudio/dygraphs")
```

...然后有这样的复选框

```{r}
library(shiny)
checkboxGroupInput("structures",
                         label = h3("Które struktury wyświetlić?"),
                         choices = series_names,
                         selected = series_names)
```

我在恶劣的环境中获得了这样的输出。任何想法如何解决这个问题?

bug

编辑:我的观点

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=Polish_Poland.1250 
[2] LC_CTYPE=Polish_Poland.1250   
[3] LC_MONETARY=Polish_Poland.1250
[4] LC_NUMERIC=C                  
[5] LC_TIME=Polish_Poland.1250    

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

other attached packages:
[1] DT_0.0.4      xts_0.9-7     zoo_1.7-11    dplyr_0.3.0.2

loaded via a namespace (and not attached):
 [1] assertthat_0.1    bitops_1.0-6      DBI_0.3.1        
 [4] devtools_1.6.1    digest_0.6.6      evaluate_0.5.5   
 [7] formatR_1.0       grid_3.1.2        htmltools_0.2.6  
[10] htmlwidgets_0.3.2 httr_0.6.0        knitr_1.8        
[13] lattice_0.20-29   lazyeval_0.1.9    magrittr_1.5     
[16] parallel_3.1.2    Rcpp_0.11.3       RCurl_1.95-4.5   
[19] RJSONIO_1.3-0     rmarkdown_0.3.10  stringr_0.6.2    
[22] tools_3.1.2       yaml_2.1.13

1 个答案:

答案 0 :(得分:0)

这是一个更多的评论,但写作添加图形和代码的答案。

在你的例子之下煮至最低限度。另外两个块不是必需的。为了避免分心,在此处发布时总是建议这样做。

---
runtime: shiny
output:
  html_document
---

```{r}
library(shiny)
checkboxGroupInput("structures",
                         label = h3("Które struktury wyświetlić?"),
                         choices = c("a","b"),
                         selected = "b")
```

尝试重现时,我在德语版Windows 7 64位上获得了类似但没有相同的输出:

enter image description here

当我在Linux / RStudio服务器/ Shiny服务器下运行时,一切都很好:

enter image description here

这可能是值得报道的错误;我以前和德国的变形金刚有类似的问题,而且Shiny团队一直很努力地解决它。我建议发布系统sessionInfo()的输出。

R version 3.1.2 (2014-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

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

loaded via a namespace (and not attached):
[1] tools_3.1.2