2016-04-14 380 views
0

是否可以在R markdown文档中内插R代码或变量值?我的意思是这样的:如何在R markdown文档中内插变量值

--- 
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

尝试使用替代以下的你{}

`r X` 

你也可以做内联的计算:

`r mean(rnorm(50))` 
+0

伟大的!非常感谢!! – user2641103