Convert a data frame into a named list

df_to_named_list(df, nameCol = 1, otherCols = 2:ncol(df))

Arguments

df

The data frame

nameCol

The column name or index that holds the names

otherCols

The other columns to include (by name or index)

Value

A named list

Examples

metabefor::df_to_named_list(
  data.frame(
    nameCol = c('name1', 'name2', 'name3'),
    contentCol = c('contents1', 'contents2', 'contents3')
  )
);
#> $name1
#>  contentCol 
#> "contents1" 
#> 
#> $name2
#>  contentCol 
#> "contents2" 
#> 
#> $name3
#>  contentCol 
#> "contents3" 
#>