r - rmarkdown yaml 中的顺序或反应参数
问题描述
我基本上有一个两层的选项组,我希望可以从中选择作为 Rmarkdown 文件中的参数。我熟悉使用参数,但想让参数 2 的选择选项取决于选择的参数 1:
如果这是一件微不足道的事情,我想象它会如何发挥作用:
示例 YAML
---
title: "Report with Reactive Parameters"
author: "Mr/Mrs. Scientist"
date: "Updated on: `r Sys.Date()`"
output:
html_document:
toc: TRUE
params:
parent_group:
label: "Select the Larger Collection"
value: "collection 1"
input: select
choices: ["collection 1", "collection 2", "collection 3 that is much larger"]
child_selection:
label: "Select a Specific Option from Parent Group:"
value: "child option 1"
input: select
choices: !r my_package::children_of_parents(parent_group = params$parent_group)
---
在这个假设的示例中,用户将首先选择更大的类别或“parent_groups”,并且基于该选择,第二个选择选项或“child_selections”将发生变化。
我包括这行my_package::children_of_parent()
只是为了演示我计划如何访问选择选项。从字面上看,只是一个将字符串作为输入并返回适当的选择向量的函数。
解决方案
推荐阅读
- python - 在没有互联网连接的计算机上安装 PyQt for Python3.9
- android - 如何在颤动中将父小部件的高度传递给子小部件?
- swift - CGPoint:调用初始化程序时没有完全匹配
- python - 所有导入都在一个文件中(如在 C 中)
- python - 使用 UPX 压缩时,Pyinstaller librosa dll 导入失败
- javascript - Android 和 Windows chrome 浏览器中在线/离线事件的行为差异
- c - 对 ac 文件中定义的函数的未定义引用
- spring-boot - 根据 Spring Boot Controller 中提供的 RequestParam,RequestBody 的不同类类型?
- python - Python,使用值中的列表对字典列表进行排序
- python - 如何将 QTable 保存到文件(.txt、.csv 等)