简体   繁体   English

R图中的Markdown不表现

[英]Markdown in R plot NOT behaving

My R code consists of: 我的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")

once I plot my graphic I do not get the Y-label(ylab) markdown to display the Mathjax(?) formula. 一旦我绘制我的图形,我没有得到Y标签(ylab)降价显示Mathjax(?)公式。 I believe I am missing a library but what? 我相信我错过了一个图书馆,但是什么?


sessionInfo() 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 

you can use the latex2exp package. 你可以使用latex2exp包。

library(latex2exp)
plot(x, type = "l", ylab = TeX("$x_{i+1}=x_i+\\epsilon_{i+1}$"), 
     xlab = "step")

在此输入图像描述

Not sure what library you think you're missing but you can use expression() from base R for this: 不确定你认为你缺少哪个库,但你可以使用基数R expression()

y_label = expression(x[i+1] ~ "=" ~ x[i]+epsilon[i+1])

plot(x, type = "l", ylab = y_label, xlab = "step")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM