我在打印消息前粘贴字符串时遇到问题。具体来说,我有:> notinld
[1] "b3" "b2"
作为要在打印消息前粘贴的字符值。
我有以下代码和结果:
> print(paste(notinld,"have not been included in the analysis due to all participants at this node for these items answering essentially the same",sep=" ",collapse=""))
[1] "b3 have not been included in the analysis due to all participants at this node for these items answering essentially the sameb2 have not been included in the analysis due to all participants at this node for these items answering essentially the same"
我不确定为什么b2会出现在这样的消息中间,并且我会将'notinld'中出现的任何字符值出现在打印消息的前面,并在它们之间用逗号表示,如:
b2,b2 "print message"
谢谢!
答案 0 :(得分:1)
我会在这里使用sprintf
:
sprintf("%s have not been included", paste(notinld, collapse = ", "))
#"b3, b2 have not been included"