回复 第5楼 的 zggjtsgzczh:前辈,我利用您#9楼的代码运行还是会出现中文问题。
运行方式就是直接点击RStudio中的Complie PDF
执行结果如下:
> grDevices::pdf.options(useDingbats = FALSE); require(knitr); opts_knit$set(concordance = TRUE); knit('test.Rnw', encoding='UTF-8')
Loading required package: knitr
Warning message:
package 'knitr' was built under R version 3.0.2
processing file: test.Rnw
|....... | 11%
ordinary text without R code
|.............. | 22%
label: setup (with options)
List of 1
$ include: logi FALSE
|...................... | 33%
ordinary text without R code
|............................. | 44%
label: unnamed-chunk-1 (with options)
List of 5
$ fig.width : num 5
$ fig.height: num 3
$ message : logi FALSE
$ tidy : logi FALSE
$ fig.align : chr "center"
Quitting from lines 19-22 (test.Rnw)
Error in grepl("\n", lines, fixed = TRUE) :
invalid multibyte string at '<98>"<2c> xlab = "X轴也是中文的",ylab="Y轴呢��<9f>")'
Calls: knit ... <Anonymous> -> <Anonymous> -> parse -> srcfilecopy -> grepl
Execution halted
我的软件配置:
knitr:1.5
RStudio:0.97.551
LyX:2.0
R:i386 3.0.1
"weave Rnw files using"选项为knitr,"Typeset LaTex into PDF using"选项为pdfLaTex。
系统为windows XP。