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

setattr should handle duplicate 'levels' if factor correctly #1142

Closed
arunsrinivasan opened this issue May 8, 2015 · 0 comments
Closed

setattr should handle duplicate 'levels' if factor correctly #1142

arunsrinivasan opened this issue May 8, 2015 · 0 comments
Assignees
Labels
Milestone

Comments

@arunsrinivasan
Copy link
Member

Compare:

x = factor(rep(1:4, each=2L))
x
# [1] 1 1 2 2 3 3 4 4
# Levels: 1 2 3 4
setattr(x, 'levels', c("a", "a", "b", "b"))
levels(x)
# [1] "a" "a" "b" "b"

with:

x = factor(rep(1:4, each=2L))
x
# [1] 1 1 2 2 3 3 4 4
# Levels: 1 2 3 4

levels(x) = c("a", "a", "b", "b")
levels(x)
# [1] "a" "b"

Reference: Comments section under this post.

@arunsrinivasan arunsrinivasan added this to the v1.9.6 milestone May 8, 2015
@arunsrinivasan arunsrinivasan self-assigned this May 8, 2015
@arunsrinivasan arunsrinivasan changed the title stator should handle duplicate 'levels' if factor correctly setattr should handle duplicate 'levels' if factor correctly May 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant