gpt4 book ai didi

r - 你如何使用 roxygen2 转义 "}"?

转载 作者:行者123 更新时间:2023-12-04 02:20:43 27 4
gpt4 key购买 nike

我正在使用 roxygen2 记录一个函数与 @example .

该示例有一个包含 } 的字符串。象征。

#' ...
#' @examples
#' \dontrun{
#' ## polyline joining the capital cities of Australian states
#' pl <- "nnseFmpzsZgalNytrXetrG}krKsaif@kivIccvzAvvqfClp~uBlymzA~ocQ}_}iCthxo@srst@"
#'
#' df_polyline <- decodepl(pl)
#' }
#' ...

构建时,示例的文档是

enter image description here

凡事在先 }被切断。

我如何逃脱 }以便它包含在示例中的字符串中?

我试过反斜杠 \{/ \\{没有运气。

更新 - 2016 年 9 月 1 日

official response我的问题来自哈德利

Fixing this is quite difficult (as far as I can it will require writing a considerably more complicated Rd parser), and it's a rare occurrence, so realistically this is never going to get high up enough on my to do list to fix it.

最佳答案

TLDR:长期修复:文件 an issue .

你“很幸运”,因为你有足够的东西}是为了克服一些 Rd 安装错误。

我什至尝试使用 @example inst/examples/ex.r并放置代码(使用 \dontrun{} 包装器,因为它在那里受支持)并且该方法会发生同样的事情,因为相同的 roxygen 解析/翻译代码似乎也在那里起作用。

  • 短期修复 #1:手动编辑生成的 Rd文件做单\}每个} .为了使您不会意外覆盖,请生成一次,进行修复,然后对该函数进行去氧化,直到修复为止。
  • 短期修复 #2:对于那段代码,字符串赋值可能发生在 \dontrun{} 之外块(这确实是导致这种情况的原因)。将其移出,您可以继续进行 roxygenizing。
  • 长期修复:向上述 URL 提交问题。
  • 关于r - 你如何使用 roxygen2 转义 "}"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37360571/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com