Skip to contents

A convenience function converting a data.frame() or a tibble().

Usage

rowlist(x)

Arguments

x

a data.frame(), a tibble(), or some other table data structure backed by a list() of columns.

Value

A list() of length nrow(x), with each element itself a named list() containing the elements in the corresponding row.

Examples


library(tibble)
(df <- tibble(x=2:1, y=list(list(1:3), list(3:4))))
#> # A tibble: 2 × 2
#>       x y         
#>   <int> <list>    
#> 1     2 <list [1]>
#> 2     1 <list [1]>
rowlist(df)
#> [[1]]
#> [[1]]$x
#> [1] 2
#> 
#> [[1]]$y
#> [[1]]$y[[1]]
#> [1] 1 2 3
#> 
#> 
#> 
#> [[2]]
#> [[2]]$x
#> [1] 1
#> 
#> [[2]]$y
#> [[2]]$y[[1]]
#> [1] 3 4
#> 
#> 
#>