Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Chapter 2. Creating a dataset > Useful functions for working with data objects - Pg. 42

42 C HAPTER 2 Creating a dataset It's available for Windows, Mac, and Unix platforms and supports the latest versions of the statistical packages we've discussed so far, as well as ODBC -accessed DBMS s such as Oracle, Sybase, Informix, and DB /2. 2.4 Annotating datasets Data analysts typically annotate datasets to make the results easier to interpret. Typi- cally annotation includes adding descriptive labels to variable names and value labels to the codes used for categorical variables. For example, for the variable age , you might want to attach the more descriptive label "Age at hospitalization (in years)." For the variable gender coded 1 or 2, you might want to associate the labels "male" and "female." 2.4.1 Variable labels Unfortunately, R's ability to handle variable labels is limited. One approach is to use the variable label as the variable's name and then refer to the variable by its position index. Consider our earlier example, where you have a data frame containing patient data. The second column, named age , contains the ages at which individuals were first hospitalized. The code names(patientdata)[2] <- "Age at hospitalization (in years)" renames age to "Age at hospitalization (in years)" . Clearly this new name is