R: How to separate character output in a loop?
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-03-18T19:57:42Z
Indexed on
2010/03/18
20:01 UTC
Read the original article
Hit count: 164
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?
© Stack Overflow or respective owner