R图中的Markdown不表现

时间:2018-02-02 15:17:43

标签: r plot formula

我的R代码包括:

set.seed(1213) # for reproducibility of random numbers
x <- cumsum(rnorm(100))
plot(x, type = "l", ylab = "$x_{i+1}=x_i+\\epsilon_{i+1}$", # <--ISSUE
xlab = "step")

一旦我绘制图形,我没有得到Y标签(ylab)降价显示Mathjax(?)公式。我相信我错过了一个图书馆,但又是什么?

sessionInfo()

R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.2

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

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

2 个答案:

答案 0 :(得分:2)

您可以使用index包。

latex2exp

enter image description here

答案 1 :(得分:1)

不确定您认为自己缺少哪个库,但可以使用R基础版y_label = expression(x[i+1] ~ "=" ~ x[i]+epsilon[i+1]) plot(x, type = "l", ylab = y_label, xlab = "step") 来实现此目的:

    EXPECT_CALL(*testMock, function1());