Skip to content

[R-Forge #2197] A a simple labels attribute like in the Hmisc package for variable descriptions #623

@arunsrinivasan

Description

@arunsrinivasan

Submitted by: Griffith Rees; Assigned to: Nobody; R-Forge link

One data management feature of stata which R lacks is descriptions of variables within the standard dataframe. The Hmisc package deals with this in a simple way: http://www.statmethods.net/input/variablelables.html. While this seems like a very trivial change, it allows large social science datasets with opaque variable names (have a look at the US Census) to actually be manageable within R without spending hours hand coding variable abbreviations to complicated variable names. If this were implemented, nicely written variable names (with spaces and special characters) could appear in tables and plots that are output straight to latex, without post-processing.

An example of how this could be used with the existing stata importer:

dta2data.table <- function(path) {
dta <- read.dta(path)
d <- data.table(dta)
setlabel(d, attr(dta, "val.labels"))
return(d)
}

Thanks again for an excellent and supremely useful project :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions