Skip to content

slice() shuffles datetime attributes #7655

@yjunechoe

Description

@yjunechoe

I'm not entirely sure what's going on here but slice() appears to shuffle the order of class and tzone attributes of datetime columns:

library(dplyr)
df <- data.frame(datetime = lubridate::now(tzone = "UTC"))

attributes(df$datetime)
#> $class
#> [1] "POSIXct" "POSIXt" 
#> 
#> $tzone
#> [1] "UTC"

attributes(slice(df, n())$datetime)
#> $tzone
#> [1] "UTC"
#> 
#> $class
#> [1] "POSIXct" "POSIXt"

This seems specific to dplyr functions that touch rows: so select() and mutate() doesn't do this but filter() and arrange() does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions