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

Support for the Date class #17

Closed
adamryczkowski opened this issue Feb 9, 2017 · 1 comment
Closed

Support for the Date class #17

adamryczkowski opened this issue Feb 9, 2017 · 1 comment

Comments

@adamryczkowski
Copy link

I'd like to include tagged missings (NAs) in the Date variable. But when I do the following

x <- rep(c(1,2),5)
x[[4]] <- tagged_na('a')
y <- as.Date(x, origin = '1992-01-01')
class(y)
#[1] "Date"
labelled(y, c("NA"=tagged_na('a')))
#Error: 'y' must be a numeric or a character vector

Is this behavior by design, or do I write a valid feature request? :-)

@larmarange
Copy link
Owner

By design (and following the haven package), the labelled class could be apply only to numeric or character vector mut not to date.

Here, you are also mixing value labels and tagged_na which are two different systems. I guess you could use tagged_na with a date:

y <- as.Date(x, origin = '1992-01-01')
y[is.na(y)] <- tagged_na("a")

but you should refer to haven package documentation.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants