Is there a knitr option to force UTF-8 encoding in included R files?

后端 未结 1 433
醉梦人生
醉梦人生 2021-01-18 06:06

I am using Windows 7, R2.15.3 and RStudio 0.97.320 with knitr knitr_1.1.6 (downloaded after Yihui fixed the \'Encoding: knitr and child files\' issue on March 12)

         


        
相关标签:
1条回答
  • 2021-01-18 06:16

    Ideally I should have an encoding argument in read_chunk(), but since you were using UTF-8, this probably works:

    read_chunk(lines = readLines("TestSpanishText.R", encoding = "UTF-8"))
    

    Please try this first. If it does not work, I will add an encoding argument. Anyway, I'm sure this definitely works (it is just slightly longer):

    con = file("TestSpanishText.R", encoding = "UTF-8")
    read_chunk(con)
    close(con)
    
    0 讨论(0)
提交回复
热议问题