Skip to content

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

Closed
@iron0012

Description

@iron0012

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

Metadata

Metadata

Assignees

Labels

bugan unexpected problem or unintended behaviorvctrs ↗️

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions