ABSTRACT

This chapter begins with examples of using the data access, searching and extraction techniques introduced in Chapter 3 to alter the entries of vectors and factors. Typical alterations demonstrated include changing entries, adding or removing data entries, renaming variables, and redefining variable classes. Then, the simplicity of transforming data in R is demonstrated, both from one numeric scale to another, and from numeric to ordinal scales. Examples of manipulating character strings for later use are provided, and the recoding of factor levels is illustrated. Next, sorting techniques for vectors and factors are demonstrated and these ideas are then extended to data frames after a demonstration of methods of altering the contents data frames through merges with other data frames, and changes in the manner in which they are structured. The chapter closes with some additional comments on merging data frames.