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

group_by with a grouping variable with missing data causes R to crash #183

Closed
jeromyanglim opened this issue Jan 18, 2014 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@jeromyanglim
Copy link

@jeromyanglim jeromyanglim commented Jan 18, 2014

It seems that group_by with missing data on the grouping variable causes R to crash

library(dplyr)
library(MASS)

names(survey) <- tolower(names(survey))
group_by(na.omit(survey), m.i) #works fine
group_by(survey), m.i) # causes r to crash
 *** caught segfault ***
address 0xfffffffd0214f288, cause 'memory not mapped'

Traceback:
 1: .Call("dplyr_grouped_df_impl", PACKAGE = "dplyr", data, symbols,     drop)
 2: grouped_df_impl(data, unname(vars), drop)
 3: grouped_df(x, value)
 4: regroup.data.frame(x, new_groups)
 5: regroup(x, new_groups)
 6: group_by(survey, m.i)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
@hadley
Copy link
Member

@hadley hadley commented Jan 18, 2014

Ooops, I thought we'd tested that case already.

@ghost ghost assigned romainfrancois Jan 18, 2014
@romainfrancois
Copy link
Member

@romainfrancois romainfrancois commented Jan 18, 2014

More precisely, this is because m.i is a factor and FactorVisitor does not take that case into account.
https://github.com/hadley/dplyr/blob/master/inst/include/dplyr/VectorVisitorImpl.h#L153

What should happen ? Should we have one group related to all NA from m.i ?

@hadley
Copy link
Member

@hadley hadley commented Jan 18, 2014

Right, NAs should just turn into another group (which by convention, would be the last group)

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

Successfully merging a pull request may close this issue.

None yet
3 participants