Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将R标记YAML中的R表达式传递给CSS参数?_R_Yaml_R Markdown - Fatal编程技术网

如何将R标记YAML中的R表达式传递给CSS参数?

如何将R标记YAML中的R表达式传递给CSS参数?,r,yaml,r-markdown,R,Yaml,R Markdown,问题是: 我开发了一个带有R减价的工具来完成这个过程,并生成一些公司月报 我一直在尝试使用以下代码自动定位用于设置此报表样式的CSS文件: --- title: "Gerador de Relatórios VANT" author: 'Empresa: International Paper Brasil' date: 'Equipe: P&D' output: html_document: css: !expr paste(dirname(d

问题是:

我开发了一个带有R减价的工具来完成这个过程,并生成一些公司月报

我一直在尝试使用以下代码自动定位用于设置此报表样式的CSS文件:

---
title: "Gerador de Relatórios VANT"

author: 'Empresa: International Paper Brasil'

date: 'Equipe: P&D'

output:

  html_document:

    css: !expr paste(dirname(dirname(rstudioapi::getSourceEditorContext()$path)), 'CSS/vant_style.css', sep = '/')
---
我不确定,但我想可能无法使用函数
rstudioapi::getSourceEditorContext()$path
,因为在编写文档时,它会在另一个会话中运行

我想这样做是因为我必须与我的老板和一些同事分享,我不希望他们需要在css文件中更改任何内容

我需要什么,还有什么可以做的吗


PS:我这样做是因为我的项目中有太多的文件夹,不仅是工具文件夹,还有更多的数据和注释,我知道将所有内容都放在一个文件夹中会更容易。

我认为你可以在YAML中呈现R代码,就像在文档正文中一样<代码>css:`r粘贴(…)`@dcruvolo我不这么认为。我已经试过这种方法了。如果我不使用函数
rstudioapi::getSourceEditorContext()$path
beacu,那么我输入代码的方式是有效的,因为我认为会话不会在rstudioapi下运行,或者类似的东西。我找到了另一种方法来实现我想要的:我正在使用
dirname()
getwd()
函数(返回当前RMD文件的路径)相关联。现在,我不必再担心向分享我的项目的每个人描述如何更改源文件夹以运行该工具。谢谢你的帮助!=)