I suggest the concatenate and print function, cat
, for this purpose. Another option is message
, which sends the output to stderr.
> i <- 9
> xsplitval <- 6.7
> cat('Splitting col ',i,' x<', xsplitval, '\n', sep="")
Splitting col 9 x<6.7
> message('Splitting col ',i,' x<', xsplitval, sep="")
Splitting col 9 x<6.7
c
is the function for combining values into a vector; it lines up the result into equally spaced columns to make looking at resulting vector easier.
> c('Splitting col ',i,' x<', xsplitval)
[1] "Splitting col " "9" " x<" "6.7"
paste
concatenates character vectors together, and sprintf
is like the C function, but both return character vectors, which are output (by default) with quotes and with numbers giving the index that each line of output starts with, so you may want to wrap them in cat
or message
.
> s1 <- paste('Splitting col ',i,' x<', xsplitval, sep=""); s1
[1] "Splitting col 9 x<6.7"
> cat(s1,'\n')
Splitting col 9 x<6.7
> s2 <- sprintf("Splitting col %i, x<%3.1f", i, xsplitval); s2
[1] "Splitting col 9, x<6.7"
> cat(s2,'\n')
Splitting col 9, x<6.7