list_name_to_df {listr}R Documentation

Add the names of list items to data frames.

Description

Add the names of list items to data frames.

Usage

list_name_to_df(in_list, column_name = ".group", skip_non_df = TRUE)

Arguments

in_list

The list to work on. Must have names.

column_name

The name of the column to add to the data frames.

skip_non_df

Whether to skip items that are not data frames.

Details

With 'column_name' you can specify the name the new columns in the data.frames should have. The default is '.group'.

Using 'skip_non_df' you can specify to omit elements from the input list that are not data frames. If FALSE an error will be thrown if elements are present that are not data frames. If TRUE (the default) then items that are not data frames will be ignored and remain unchanged.

Value

The input list with the name of the list item added in a new column for all data frames.

Examples

my_list <- list(group1 = data.frame(x = 1:10, y = rnorm(10)),
                group2 = data.frame(x = 1:10, y = rnorm(10)))
list_name_to_df(my_list)

[Package listr version 0.1.0 Index]