quote(# this is a comment)
我怎样才能做类似上面的事情?
最佳答案
quote()
在其 wholeSrcref
属性中捕获原始代码,该属性保留注释:
x <- quote({
## This is a comment
})
src <- attributes(x)$wholeSrcref # <--- preserves the comment
但是,这会返回 srcref
类的对象,而不是可以传递给 eval()
的真实表达式。根据您想要执行的操作,您可能会发现 these functions for manipulating srcref objects有用。例如,
as.character(src)[2]
[1] " ## This is a comment"
关于r - 在 R 中,如何使用 quote 或 bquote 引用注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64905464/