为什么 knitr 会更改我的 Rmarkdown 文档?
Why is knitr changing my Rmarkdown document?
我正在尝试使用 Rmarkdown 和 knitr 呈现 pdf。此过程更改我的脚本的以下行:
"`r format(Sys.time(), '%B %d, %Y')`"
至:
'`r format(Sys.time(), ''%B %d, %Y'')`'
具体来说,''%B %d, %Y''
周围的这些双单引号正在抛出消息:
Error in yaml::yaml.load(enc2utf8(string), ...) :
Scanner error: while scanning for the next token at line 5, column 31found character that cannot start any token at line 5, column 31
为什么 knitr 会自动进行这些调整,是否可以修复/关闭它?
在此先感谢您的任何建议。
我已经检查了这里的答案 YAML current date in rmarkdown 但不幸的是没有解决我的问题
一个解决方案可能是
{r format(Sys.time(), "%a %b %d %X %Y %Z")}
更多信息可以在这里找到https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html,如果你想改变计时的结构
%a 是该平台当前语言环境中的缩写工作日名称。
%b 是该平台当前语言环境中的缩写月份名称。
%d 是十进制数 (01–31)
中的日期
%X 是时间。输出特定于语言环境
%Y 是带世纪的年份。
%Z为字符串形式的时区缩写(没有则为空)
我正在尝试使用 Rmarkdown 和 knitr 呈现 pdf。此过程更改我的脚本的以下行:
"`r format(Sys.time(), '%B %d, %Y')`"
至:
'`r format(Sys.time(), ''%B %d, %Y'')`'
具体来说,''%B %d, %Y''
周围的这些双单引号正在抛出消息:
Error in yaml::yaml.load(enc2utf8(string), ...) :
Scanner error: while scanning for the next token at line 5, column 31found character that cannot start any token at line 5, column 31
为什么 knitr 会自动进行这些调整,是否可以修复/关闭它?
在此先感谢您的任何建议。
我已经检查了这里的答案 YAML current date in rmarkdown 但不幸的是没有解决我的问题
一个解决方案可能是
{r format(Sys.time(), "%a %b %d %X %Y %Z")}
更多信息可以在这里找到https://stat.ethz.ch/R-manual/R-devel/library/base/html/strptime.html,如果你想改变计时的结构
%a 是该平台当前语言环境中的缩写工作日名称。
%b 是该平台当前语言环境中的缩写月份名称。
%d 是十进制数 (01–31)
中的日期%X 是时间。输出特定于语言环境
%Y 是带世纪的年份。
%Z为字符串形式的时区缩写(没有则为空)