【发布时间】:2011-01-29 04:48:14
【问题描述】:
我正在寻找将字符串列表粘贴在一起以进入 SQL 语句的最佳方式...我在使用分隔栏时遇到问题 |在我不想打印时在开头打印:
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 语句的更好方法?
【问题讨论】:
标签: r loops character separator