Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for turning on/off labelled columns (particularly Stata files) #56

Closed
nickbloom opened this issue Mar 25, 2015 · 4 comments
Closed

Comments

@nickbloom
Copy link

A simple request: could you add an option to turn off labelling for labeled Stata files?

I'd be fine with one that dropped labels altogether, returning only the numeric values underlying the Stata labels.

The main concern is that dplyr still doesn't support labelled data.frames, but I'm worried about compatibility with other packages, too.

@hadley
Copy link
Member

hadley commented Apr 7, 2015

Are you worried about variable labels or value labels?

@nickbloom
Copy link
Author

Either/both. I'd be happy to have both labels if standard vector classes (e.g. numeric, character) can be preserved. But I am willing to forgo labeling of any kind that necessitates adding the class "labelled" to a variable, as with rl$type below:

> class(rl$int_date)
[1] "numeric"
> class(rl$type)
[1] "labelled"
> str(rl$type)
Class 'labelled'  atomic [1:35556] 1 1 1 1 1 1 1 1 1 1 ...
  ..- attr(*, "label")= chr "Type of sample used"
  ..- attr(*, "labels")= Named int [1:2] 1 2
  .. ..- attr(*, "names")= chr [1:2] "RDD" "Callback"

rl$type is actually a numeric vector, but is classed "labelled." I'm envisioning it as an "unlabeled" boolean function parameter that (default can be TRUE), that, when FALSE, returns a standard vector class of that column, which would be either "numeric" or "integer" for rl$type. I always have a codebook to reference alongside analysis, so labels aren't that important, at least to me.

@hadley
Copy link
Member

hadley commented Apr 7, 2015

In that case, you should do df[] <- lapply(df, zap_labels)

@hadley hadley closed this as completed Apr 7, 2015
@nickbloom
Copy link
Author

Excellent. Thanks!

@lock lock bot locked and limited conversation to collaborators Jun 27, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants