[datatable-help] Variable labels suggestion

Tom Short tshort.rlists at gmail.com
Thu Jul 28 19:43:24 CEST 2011


On Thu, Jul 28, 2011 at 8:26 AM, Griffith Rees
<griffith.rees at sociology.ox.ac.uk> wrote:
> I think this page quite succinctly describes this issue:
> http://www.statmethods.net/input/variablelables.html

It would be easy to add to data.table. You could also add support
outside of data.table by writing label.data.table and similar
functions. Actually using the labels for useful things is more
difficult. I often find it useful just to use more verbose variable
names that include spaces as follows:

> dt <- data.table(`My first column` = 1:3, `A character column` = letters[1:3], check.names = FALSE)
> str(dt)
Classes 'data.table' and 'data.frame':  3 obs. of  2 variables:
 $ My first column   : int  1 2 3
 $ A character column: Factor w/ 3 levels "a","b","c": 1 2 3

That way, columns look better with automatic plotting and with lattice
or ggplot legends.

- Tom


More information about the datatable-help mailing list