R: How to separate character output in a loop?
- by John
I'm blanking on the best way to paste a list of strings together to go into an SQL statement... I'm having trouble with the separator bar | printing at the beginning when I don't want it to:
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"
I just want it to print out "blah|blah|blah|blah". Do I need a nested loop, or is there a better itterator in R for doing this? Or perhaps a better way to input SQL statements?