nathaneastwood / poorman

A poor man's dependency free grammar of data manipulation
https://nathaneastwood.github.io/poorman/
Other
340 stars 15 forks source link

Fix arrange() with character vectors #99

Closed etiennebacher closed 2 years ago

etiennebacher commented 2 years ago

Close #85

df <- data.frame(x = head(letters), stringsAsFactors = FALSE)
poorman::arrange(df, -x)
#>   x
#> 6 f
#> 5 e
#> 4 d
#> 3 c
#> 2 b
#> 1 a

set.seed(2022)
df <- data.frame(
  x = sample(c("A", "B"), 6, replace = TRUE),
  y = 1:6
)
df
#>   x y
#> 1 B 1
#> 2 A 2
#> 3 B 3
#> 4 A 4
#> 5 A 5
#> 6 B 6
poorman::arrange(df, -x, y)
#>   x y
#> 1 B 1
#> 3 B 3
#> 6 B 6
#> 2 A 2
#> 4 A 4
#> 5 A 5

Created on 2022-07-28 by the reprex package (v2.0.1)