Skip to content

Issue with gather and time intervals #333

@urskalbitzer

Description

@urskalbitzer

I am trying to use gather with a data frame that contains one column with intervals created with lubridate::interval.

Sys.setenv(TZ = "Canada/Eastern")
library(lubridate, warn.conflicts = FALSE)
library(tidyr)
library(dplyr, warn.conflicts = FALSE)

df <- tibble(period = interval(as.Date("2010-01-01"), as.Date("2010-02-01")),
             var1 = 1,
             var2 = 2)

gather(df, var_name, var_value, var1, var2)
#> # A tibble: 2 x 3
#>                           period var_name var_value
#>                   <S4: Interval>    <chr>     <dbl>
#> 1 2010-01-01 UTC--2010-02-01 UTC     var1         1
#> 2                         NA--NA     var2         2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behaviorpivoting ♻️pivot rectangular data to different "shapes"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions