【发布时间】:2021-11-16 09:04:10
【问题描述】:
当我在 RStudio 中创建 R sn-p 以下情况时,当我希望在我的 sn-p 中使用文字 $sign 时,来自 sn-p 变量的 $ 符号会产生问题(例如,mtcars$cyl ):
snippet cor_binary
ltm::biserial.cor(${1:df}\$ ${2:continuous_field}, ${1:df}\$ ${3:binary_field}, use = c("complete.obs"), level = 2)
上面的 sn-p 在 df 和 field 之间产生了一个不需要的空白:
# output
ltm::biserial.cor(df$ continuous_field, df$ binary_field, use = c("complete.obs"), level = 2)
我的 sn-p 中没有空格会在输出中产生不同的问题:
snippet cor_binary
ltm::biserial.cor(${1:df}\$${2:continuous_field}, ${1:df}\$${3:binary_field}, use = c("complete.obs"), level = 2)
# output
ltm::biserial.cor(df\{2:continuous_field}, df\{3:binary_field}, use = c("complete.obs"), level = 2)
如何在没有 sn-p 的情况下在 mtcars$cyl 的上下文中包含 $ 符号
【问题讨论】:
-
你没有告诉我们什么是“code sn-ps”。这些是 RStudio 中的东西吗? (如果是这样,您应该使用该标签,而不是“r”。)
-
我已经相应地更新了这个问题。谢谢@user2554330
标签: r rstudio code-snippets