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

left_join() over empty grouped data frame produces error in dplyr 0.7.5 #3587

Closed
javierluraschi opened this issue May 21, 2018 · 4 comments
Closed
Milestone

Comments

@javierluraschi
Copy link
Contributor

@javierluraschi javierluraschi commented May 21, 2018

Found out that this works in dplyr 0.7.4:

library(dplyr)
x <- data_frame(name = c("a", "b"), type = c("integer", "string"))
x %>% group_by(name) %>%
    select(name) %>%
    setdiff(select(x, name)) %>%
    left_join(x, by = "name")
# A tibble: 0 x 2
# Groups:   [?]
# ... with 2 variables: name <chr>, type <chr>

but not in dplyr 0.7.5:

Error in grouped_df_impl(out, vars$alias[groups_in_alias], group_drop(x),  : 
  no variables to group by

We found and pushed a fix for sparklyr with sparklyr/sparklyr#1510, but reporting to consider fixing upstream.

@ejmacrae1
Copy link

@ejmacrae1 ejmacrae1 commented May 22, 2018

Hi,

I have a similar issue; looks like it's related to yours. The below works in dplyr 0.7.4 but not in 0.7.5:

k <- data.frame(id=letters[1:5], col1=c("ha", "ha", NA, "ha", "ha"), stringsAsFactors=F)
k %>%
  group_by(id) %>%
  summarise(temp_col=first(col1[!is.na(col1)]))

Error is: "Error in summarise_impl(.data, dots) :
Column temp_col must be length 1 (a summary value), not 0"

While the expected output is:

   id temp_col
1  a       ha
2  b       ha
3  c     <NA>
4  d       ha
5  e       ha

romainfrancois added a commit that referenced this issue May 28, 2018
reconstruct groups metadata for set operations. closes #3587
@krlmlr
Copy link
Member

@krlmlr krlmlr commented Jun 25, 2018

Is it worth fixing this in v0.7.6?

@krlmlr krlmlr reopened this Jun 25, 2018
@krlmlr krlmlr added this to the 0.7.6 milestone Jun 25, 2018
@ejmacrae1
Copy link

@ejmacrae1 ejmacrae1 commented Jun 25, 2018

In my opinion, yes (unless it's desired behaviour).

@krlmlr krlmlr closed this in a8dc325 Jun 30, 2018
@lock
Copy link

@lock lock bot commented Dec 27, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Dec 27, 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