Skip to content

as.period fails for grouped data #930

@julianbarg

Description

@julianbarg

as.period fails with a nondescript error when applied to a grouped dataframe.

df <- data.frame(group = c("a","a","b"),
                 p1 = as.Date(c("2020-10-23", "2020-10-24", "2020-10-25")), 
                 p2 = as.Date(c("2020-10-26", "2020-10-27", "2020-10-28")))

#This succeeds
df %>%
  mutate(interval = as.period(interval(start = p1, end = p2)))

# This throws the error message
df %>%
  group_by(group) %>%
  mutate(interval = as.period(interval(start = p1, end = p2)))

Error message:
Error: Problem with mutate() input interval.
x Internal error in vec_proxy_assign_opts(): proxy of type double incompatible with value proxy of type integer.
ℹ Input interval is as.period(interval(start = p1, end = p2)).
ℹ The error occurred in group 2: group = "b".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions