如何在R markdown文档中插入变量值

时间:2016-04-14 13:40:50

标签: r r-markdown

是否可以在R降价文档中插入R代码或变量值?我的意思是:

---
title: "Behavioural report"
author: "My name"
date: "Some date here"
output: pdf_document
---

```{r echo=FALSE}
X = 1.28473
```

Suppose that this is my R markdown document and I want to say that the value
of the variable X = {Here I want the value of X to appear}. And then blah...

所以我希望值1.28473出现在文本' X ='之后。

提前致谢!

1 个答案:

答案 0 :(得分:2)

尝试使用以下内容代替{}

`r X`

您还可以进行内联计算:

`r mean(rnorm(50))`