[datatable-help] Variable labels suggestion

Matthew Dowle mdowle at mdowle.plus.com
Thu Jul 28 21:11:57 CEST 2011


The toLatex aspect struck a chord. I sometimes embed the string 'PCT'
into the column name and then gsub("PCT","\%") just before output to
latex. Maybe a label would be more robust and could allow more complex
latex expressions in the column heading.  Long column names with spaces
are ok, but that may make it cumbersome to follow the advice to use
names not positions in j expressions.  But how would the latex output
command know to use the labels rather than the names? And would
data.table need to know about column labels to carry them through
subsets and joins etc?

Matthew


On Thu, 2011-07-28 at 13:51 -0400, Chris Neff wrote:
> I think this is definitely out of the scope of data.table.
> 
> On 28 July 2011 13:43, Tom Short <tshort.rlists at gmail.com> wrote:
>         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
>         
>         _______________________________________________
>         datatable-help mailing list
>         datatable-help at lists.r-forge.r-project.org
>         https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
>         
> 
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help




More information about the datatable-help mailing list