Having a bit of a mental block. I am sure I found a function to print iteration numbers in a for loop that was not print and not cat, but gave the same output as cat below.
> for(i in 10^(1:5)) print(i)
[1] 10
[1] 100
[1] 1000
[1] 10000
[1] 1e+05
> for(i in 10^(1:5)) cat(i, "\n")
10
100
1000
10000
1e+05
I cannot see any reference to it in the R help files for print and cat. Tried googling for it, but not getting anywhere.
It’s easy enough to define a wrapper function around
cat:Use it:
Or you can use
message(which has the added benefit that in some code editors, e.g. Eclipse, the messages appear in a different colour):