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

WIP: Basic API for tagged missing values #175

Closed
wants to merge 21 commits into from
Closed

WIP: Basic API for tagged missing values #175

wants to merge 21 commits into from

Conversation

hadley
Copy link
Member

@hadley hadley commented Jun 6, 2016

Fixes #170

To do:

  • ensure labelled class prints tagged missing values specially
  • check that as_factor() can re-label tagged missings
  • update vignette with examples (including as_factor())
  • read SAS/Stata tagged missing values
  • read SPSS missing ranges

if (TYPEOF(x) != STRSXP)
Rf_errorcall(R_NilValue, "`x` must be a character vector");

int n = Rf_length(x);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to support long vectors here?

@itsdalmo
Copy link

itsdalmo commented Jun 9, 2016

Your last commit referenced the wrong issue I think. #177 is regarding variable label, did you mean #172?

Would you consider moving the sort to the end, so missing labels are sorted in relation to the existing?

E.g. changing to something like:

# Replace each value with its label
vals <- unique(x)
levs <- replace_with(vals, unname(labels), names(labels))
# Ensure all labels are preserved
levs <- sort(c(setNames(vals, levs), labels))
levs <- unique(names(levs))

Would make it so:

s1 <- labelled(c(1, 4), c("Agree" = 1, "Neutral" = 2, "Disagree" = 3, "Don't know" = 5))
as_factor(s1) 
# Returns:
#> Levels: Agree Neutral Disagree 4 Don't know
# Instead of:
#>  Levels: Agree 4 Neutral Disagree Don't know

@hadley
Copy link
Member Author

hadley commented Jun 9, 2016

Closing because it's now so massive that it's impossible to review.

@hadley hadley closed this Jun 9, 2016
@hadley hadley removed the in progress label Jun 9, 2016
@lock lock bot locked and limited conversation to collaborators Jun 26, 2018
@hadley hadley deleted the tagged-na branch April 8, 2021 21:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants