2016-04-14 384 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