在Knitr中使用导入的UTF-8字符和R.

时间:2014-10-21 17:31:18

标签: r knitr

我实际上是从* .csv导入UTF-8格式的数据(名称),并希望稍后将该名称打印到xtable中并使用Knitr创建文档,通过* .Rmd> * .md> PDF。

示例:

data <- paste("úáźýžč",sep="") 

现在在Rmd文件中我做:

```{r}
print(data)
```

我收到错误:

pandoc.exe: Cannot decode byte '\xfa': Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream

如何处理?感谢

编辑: sessionInfo()

R version 3.1.1 (2014-07-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
    LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

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

other attached packages:
[1] rmarkdown_0.3.3     gdata_2.13.3        xlsx_0.5.7          xlsxjars_0.6.1      rJava_0.9-6          
    dplyr_0.3.0.2       XML_3.98-1.1        sp_1.0-15          
[9] RCurl_1.95-4.3      bitops_1.0-6        xts_0.9-7           msm_1.4             tseries_0.10-       
    32     knitr_1.7           gridExtra_0.9.1     plyr_1.8.1            
[17] xtable_1.7-4        texreg_1.33         latticeExtra_0.6-26 RColorBrewer_1.0-5   
     lattice_0.20-29     forecast_5.6        timeDate_3010.98    zoo_1.7-11         
[25] coxrobust_1.0       survival_2.37-7     stringr_0.6.2       data.table_1.9.4    
     markdown_0.7.4     

     loaded via a namespace (and not attached):
 [1] assertthat_0.1   chron_2.3-45     colorspace_1.2-4 DBI_0.3.1        digest_0.6.4   
     evaluate_0.5.5   expm_0.99-1.1    formatR_1.0      fracdiff_1.4-2  
 [10] gtools_3.4.1     htmltools_0.2.6  magrittr_1.0.1   Matrix_1.1-4     mvtnorm_1.0-0      
      nnet_7.3-8       parallel_3.1.1   quadprog_1.5-5   Rcpp_0.11.3     
 [19] reshape2_1.4     tools_3.1.1 

0 个答案:

没有答案