The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Introduction to splutil

Richard Aubrey White

2022-04-28

Splitting

splutil::easy_split(letters[1:20], size_of_each_group = 3)
#> $`1`
#> [1] "a" "b" "c"
#> 
#> $`2`
#> [1] "d" "e" "f"
#> 
#> $`3`
#> [1] "g" "h" "i"
#> 
#> $`4`
#> [1] "j" "k" "l"
#> 
#> $`5`
#> [1] "m" "n" "o"
#> 
#> $`6`
#> [1] "p" "q" "r"
#> 
#> $`7`
#> [1] "s" "t"
splutil::easy_split(letters[1:20], number_of_groups = 3)
#> $`1`
#> [1] "a" "b" "c" "d" "e" "f" "g"
#> 
#> $`2`
#> [1] "h" "i" "j" "k" "l" "m" "n"
#> 
#> $`3`
#> [1] "o" "p" "q" "r" "s" "t"

Unnesting data.frames

x <- list(
  list(
    "a" = data.frame("v1"=1),
    "b" = data.frame("v2"=3)
  ),
  list(
    "a" = data.frame("v1"=10),
    "b" = data.frame("v2"=30),
    "d" = data.frame("v3"=50)
  )
)
print(x)
#> [[1]]
#> [[1]]$a
#>   v1
#> 1  1
#> 
#> [[1]]$b
#>   v2
#> 1  3
#> 
#> 
#> [[2]]
#> [[2]]$a
#>   v1
#> 1 10
#> 
#> [[2]]$b
#>   v2
#> 1 30
#> 
#> [[2]]$d
#>   v3
#> 1 50
splutil::unnest_dfs_within_list_of_fully_named_lists(x)
#> $a
#>    v1
#> 1:  1
#> 2: 10
#> 
#> $b
#>    v2
#> 1:  3
#> 2: 30
#> 
#> $d
#>    v3
#> 1: 50

Describing lists

splutil::is_fully_named_list(list(1))
#> [1] FALSE
splutil::is_fully_named_list(list("a"=1))
#> [1] TRUE

splutil::is_all_list_elements_null_or_df(list(data.frame()))
#> [1] TRUE
splutil::is_all_list_elements_null_or_df(list(1, NULL))
#> [1] FALSE

splutil::is_all_list_elements_null_or_list(list(1, NULL))
#> [1] FALSE
splutil::is_all_list_elements_null_or_list(list(list(), NULL))
#> [1] TRUE

splutil::is_all_list_elements_null_or_fully_named_list(list(list(), NULL))
#> [1] FALSE
splutil::is_all_list_elements_null_or_fully_named_list(list(list("a" = 1), NULL))
#> [1] TRUE

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.