nathaneastwood / poorman

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

Feat: implement lst() #108

Closed etiennebacher closed 2 years ago

etiennebacher commented 2 years ago

Close #93. This PR builds on the code that you have written in #93, I just added a few things to deal with names and to match with the examples of tibble::lst(). For the tests, I only took those from tibble::lst().

Examples:

suppressPackageStartupMessages({
  library(poorman)
})

lst(n = 5, x = runif(n))
#> $n
#> [1] 5
#> 
#> $x
#> [1] 0.8556188 0.4592575 0.8778909 0.6046387 0.5285325

lst(1:3, z = letters[4:6], runif(3))
#> $`1:3`
#> [1] 1 2 3
#> 
#> $z
#> [1] "d" "e" "f"
#> 
#> $`runif(3)`
#> [1] 0.9535917 0.5555817 0.6382548

a <- 1:3
b <- letters[4:6]
lst(a, b)
#> $a
#> [1] 1 2 3
#> 
#> $b
#> [1] "d" "e" "f"

lst(b = 1, a = b, a = b + 1, b = a)
#> $b
#> [1] 1
#> 
#> $a
#> [1] 1
#> 
#> $a
#> [1] 2
#> 
#> $b
#> [1] 2

Created on 2022-08-10 by the reprex package (v2.0.1)

etiennebacher commented 2 years ago

@nathaneastwood thanks! I think I've addressed all your comments

nathaneastwood commented 2 years ago

Thanks a lot