【问题标题】:How to set text coding in the R markdown interactive document?R markdown交互文档中如何设置文本编码?
【发布时间】:2014-12-22 14:53:16
【问题描述】:

我在 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)
```

我得到这样的输出在错误的编码中。任何想法如何解决这个问题?

编辑:我的看法

> 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

【问题讨论】:

    标签: r text encoding markdown shiny


    【解决方案1】:

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

    下面的示例归结为最低限度。另外两个块不是必需的。为避免分心,在此处发帖时始终建议这样做。

    ---
    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 位上得到了类似但没有相同的输出:

    当我在 Linux/RStudio server/Shiny server 下运行时,一切正常:

    这可能是一个值得报告的错误;我之前也遇到过类似的德国元音变音问题,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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 2019-04-13
      • 2011-04-20
      相关资源
      最近更新 更多