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

do() loses ordering of ordered factors #1112

Closed
ateucher opened this issue Apr 28, 2015 · 1 comment
Closed

do() loses ordering of ordered factors #1112

ateucher opened this issue Apr 28, 2015 · 1 comment
Assignees
Milestone

Comments

@ateucher
Copy link
Contributor

@ateucher ateucher commented Apr 28, 2015

When executing an arbitrary function on a grouped data frame using do(), ordered factors lose their order:

library(dplyr)
l <- c("a", "b", "c", "d")
id <- factor(c("a", "c", "d"), levels = l, ordered = TRUE)
df <- data.frame(id = rep(id, 2), val = rnorm(6))

levels(df$id)
## [1] "a" "b" "c" "d"

is.ordered(df$id)
## [1] TRUE

out <- group_by(df, id) %>% 
  do(na.omit(.))

levels(out$id) # Levels are retained
## [1] "a" "b" "c" "d"

is.ordered(out$id) # Loses ordering
## [1] FALSE
@hadley hadley added this to the 0.5 milestone May 19, 2015
@hadley
Copy link
Member

@hadley hadley commented May 19, 2015

This is probably a bind_rows() problem

@romainfrancois romainfrancois self-assigned this Aug 14, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants