在R中打印消息前面的字符串中粘贴字符值



在打印消息前粘贴字符串时遇到问题。具体来说,我有:> 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"

谢谢!

我会在这里使用sprintf

sprintf("%s have not been included", paste(notinld, collapse = ", "))
#"b3, b2 have not been included"

最新更新