I want an output like this using a loop function:
> stat-1, stat-2, stat-3, stat4, stat5.
Currently this is my code:
x<-0;
while (x <= 10)
{
x <- x+1
z <- paste('stat-', x, collapse = "," )
print(z)
}
But iam getting output like this:
[1] "stat- 1"
[1] "stat- 2"
[1] "stat- 3"
[1] "stat- 4"
[1] "stat- 5"
How can i get the output in single line?
paste('stat_', x, collapse=",")wherex <- 1:10collapse=", "will insert a space after the comma.-and the number, use:paste0('stat-', x, collapse = "," )