Basic construction
paste("on the ", counter, "rd count: ", k, sep="")
You need to be a little smart to choose the correct suffix for the digit (i.e., "rd" after 3, "th" after 4-9, etc. There is a function here:
suffixSelector <- function(x) { if (x%%10==1) { suffixSelector <- "st" } else if(x%%10==2) { suffixSelector <- "nd" } else if(x%%10==3) { suffixSelector <- "rd" } else { suffixSelector <- "th" }
}
Thus:
suffix <- suffixSelector(counter) paste("on the ", counter, suffix, " count: ", k, sep="")
You need to set the sep argument because by default paste inserts a space between the lines.
Drew steen
source share