我对将字符串列表粘贴到一起以进入SQL语句的最佳方法是空白的......我遇到了分隔条问题|在我不想要的时候开始打印:R:如何分离循环中的字符输出?
foo = "blah"
paste_all_together = NULL
for (n in 1:4) {
paste_together = paste(foo ,sep = "")
paste_all_together = paste(paste_all_together, paste_together, sep = "|")
}
> paste_all_together
[1] "|blah|blah|blah|blah"
我只是想让它打印出“blah | blah | blah | blah”。我是否需要一个嵌套循环,或者在R中有更好的传播器吗?或者更好的方式来输入SQL语句?
谢谢,但字符串是不同的,所以〜unutbu的回答最合适 – John 2010-03-18 21:16:29
@John你的问题和示例代码表明字符串是相同的。下次您可以提供所有有问题的信息。 – Marek 2010-03-18 22:13:46
是的,你是对的。 – John 2010-03-19 20:15:24