[R] "labels" attached to variable names

Frank E Harrell Jr f.harrell at vanderbilt.edu
Thu Jan 6 17:19:21 CET 2005


Denis Chabot wrote:
> Hi,
> 
> Can we attach a more descriptive "label" (I may use the wrong  
> terminology, which would explain why I found nothing on the FAQ) to  
> variable names, and later have an easy way to switch to these labels in  
> plots? I fear this is not possible and one must enter this by hand as  
> ylab and xlab when making plots.
> 
> Thanks in advance,
> 
> Denis Chabot

The Hmisc package supports this:

label(x) <- 'Some Label'
describe(x)            # uses variable name and label
plot(x, y, xlab=label(x))
Better: xYplot(x, y)   # label used automatically

And if you do units(x) <- 'whatever units of measurement'  then xYplot, 
describe, and other Hmisc functions will include the units (in a 
different font on graphs or when using latex()).

Frank

-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list