Skip to content

uncount() should error for non-integer weights #1069

@mgirlich

Description

@mgirlich

uncount() currently works with non-integer weights where it probably should not. Also the error message for negative weights is quite unclear.

library(tidyr)

# no error
tibble(x = c("a", "b"), n = c(1, 0.5)) %>% 
  uncount(n)
#> # A tibble: 1 x 1
#>   x    
#>   <chr>
#> 1 a

# unclear error message
tibble(x = c("a", "b"), n = c(1, -1)) %>% 
  uncount(n)
#> Error in rep(seq_nrow(data), w): invalid 'times' argument

Created on 2020-12-07 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementpivoting ♻️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