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

Indexing (non)missing values using first() inside of summarise() no longer works. #1980

Closed
iron0012 opened this issue Jun 28, 2016 · 6 comments
Assignees
Labels
bug an unexpected problem or unintended behavior vctrs ↗️
Milestone

Comments

@iron0012
Copy link

iron0012 commented Jun 28, 2016

I used to be able to use the following code to get the first non-missing value within a group, but it no longer works. Now I get "Error: Unsupported vector type language."
Rolling back to 0.4.3 confirms that it was the update to 0.5 that caused this change in behavior.

ids <- c(1,1,2,2,3,3)
data_column <- c(NA,1,2,3,3,NA)
df <- data.frame(ids,data_column)

df %>% 
group_by(ids) %>% 
summarise(data_column_first = first(data_column[!is.na(data_column)]))

What I wanted the code above to return is something like:

ids data_column_first
1 1
2 2
3 3

I don't know if this is a bug, a feature, a problem with the configuration of my environment, or if it's just a specific manifestation of some more general bug or feature, but it also occurs when trying to use last() in the same context instead of first().

Also, if you were to tell me a better alternative way to accomplish what I'm trying to do, I wouldn't complain! :D

@py-b
Copy link

py-b commented Jun 30, 2016

Hello,

I have the same kind of problem.
This doesn't seem to be related to NAs in the data.

@alexsanjoseph
Copy link

alexsanjoseph commented Jul 7, 2016

👍 Have the same issue with the 0.5.0 update

@julou
Copy link

julou commented Aug 29, 2016

same problem here with other single-table verbs (mutate, filter) since upgrading to dplyr0.5
the current workaround is obviously to use head, tail and [[
A fix would be really helpful though!

@krlmlr
Copy link
Member

krlmlr commented Nov 7, 2016

Thanks, confirmed. Would you like to contribute a testthat test?

@krlmlr krlmlr added the bug an unexpected problem or unintended behavior label Nov 7, 2016
@hadley
Copy link
Member

hadley commented Feb 22, 2017

Minimal reprex:

library(dplyr, warn.conflicts = FALSE)

tibble(x = 1:3) %>%  summarise(f = first(x[-1]))
#> Error in summarise_impl(.data, dots): Unsupported vector type language

@hadley
Copy link
Member

hadley commented Feb 27, 2017

@krlmlr I assume this is the same root cause as #946 - we should not use the hybrid evaluator here. How hard is it to add a branch for these cases?

@krlmlr krlmlr added this to the data frame 2 milestone Feb 27, 2017
@krlmlr krlmlr self-assigned this Feb 27, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior vctrs ↗️
Projects
None yet
Development

No branches or pull requests

6 participants