Character Vectors

Character quantities and character vectors are used frequently in ., for example as plot labels. Where needed they are denoted by a sequence of characters delimited by the double quote character. E. g. "x-values", "New iteration results".

Character vectors may be concatenated into a vector by the c() function; examples of their use will emerge frequently.

The paste() function takes an arbitrary number of arguments and concatenates them into a single character string. Any numbers given among the arguments are coerced into character strings in the evident way, that is, in the same way they would be if they were printed. The arguments are by default separated in the result by a single blank character, but this can be changed by the named parameter, sep=string, which changes it to string, possibly empty.

For example

labs <- paste(c("X","Y"), 1:10, sep="")

makes labs into the character vector

("X1", "Y2", "X3", "Y4", "X5", "Y6", "X7", "Y8", "X9", "Y10")
Note particularly that recycling of short lists takes place here too; thus c("X", "Y") is repeated 5 times to match the sequence 1:10.



Jeff Banfield
2/13/1998