我很难在RMarkdown中显示源脚本的结果。
  
  
   举个例子,我有一个简单的R脚本,名为“Values”。R'仅包含:
  
  
   
    values <- c(5, 3, 7)
   
  
  
   然后我有一份RMarkdown文档“价值报告”。Rmd',看起来像这样:
  
  ---
title: Values report.
date: 2023-11-21
output: html_document
---
```{r setup, include = FALSE]
source("filepath/Values.R")
```
There are two values we are interested in, being `values[1]` and `values[2]`. We are not interested in `values[3]`.
  
   您可以将文件路径替换为您的文件路径。
  
  
   --
  
  
   
    点击“编织”按钮后输出
   
   :
  
  
   “我们感兴趣的两个价值观是
   
    values[1]
   
   和
   
    values[2]
   
   。我们对不感兴趣
   
    values[3]
   
   。”
  
  
   
    预期输出
   
   :
  
  
   “我们感兴趣的有两个值,分别是5和3。我们对7不感兴趣。”
  
  
   --
  
  
   我也尝试过使用
   
    rmarkdown::render("Values Report.Rmd")
   
   并得到了与上述相同的输出(不是我所期望的)。不过,当我使用
   
    rmarkdown::render
   
   --我看得出来
   
    values
   
   显示在我的“环境”选项卡中。
  
  
   我知道我可以将代码复制到RMarkdown文件中,而不是源代码,但我的实际脚本要复杂得多,我更喜欢将其与分开。Rmd文件。
  
  
   
    我该如何修改我的。Rmd文件,所以我得到了预期的输出?