简体   繁体   English

如何在 R Markdown 的表格正文中显示希腊字母?

[英]How to display greek letters in the body of a table in R Markdown?

I wish to display greek letter alpha in the table generated by the following code in R Markdown.我希望在 R Markdown 中以下代码生成的表格中显示希腊字母 alpha。 How can I do it?我该怎么做? Thanks!谢谢!

rows = 1:100

cols = c(0.4, 0.2, 0.1, 0.05, 0.025, 0.01, 0.005, 0.001)

Q = NULL

for (a in rows){

  for (b in cols){

    q = qt(1-b, a)

    Q = append(Q,q)

  }

}

DF = data.frame(matrix(round(Q,3), ncol=8, byrow=TRUE))
DF= rbind(as.character(cols), DF)
DF = cbind(c("df/alpha",as.character(rows)), DF)

DF = unname(DF)
kable(DF)

Use $ notation in strings to insert LaTeX symbols, including Greek letters.在字符串中使用$表示法来插入 LaTeX 符号,包括希腊字母。 Like this:像这样:

DF = cbind(c("$\\alpha$",as.character(rows)), DF)

If you knit kable(DF) , you'll see alpha appear in the first column header.如果您编织kable(DF) ,您会看到 alpha 出现在第一列标题中。 Note that the symbol will not appear in the R console - you have to knit to see it.请注意,该符号不会出现在 R 控制台中 - 您必须编织才能看到它。

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

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