|
DATA MINING
Desktop Survival Guide by Graham Williams |
|
|||
A typical usage of paste is to build a label vector to be used in a plot. The labels may want to include both the variable values being plotted and perhaps the percentage of observations having that value.
> labels <- c("A", "B", "C", "D")
> per <- c(25, 10, 15, 45)
> paste(labels, rep(" (", 4), per, rep("%)",4), sep="")
[1] "A (25%)" "B (10%)" "C (15%)" "D (45%)"
> sprintf("%s (%d%%)", labels, per)
[1] "A (25%)" "B (10%)" "C (15%)" "D (45%)"
|