list2df function

Convert list of vectors to data.frame with item, value, name

Convert list of vectors to data.frame with item, value, name

list2df(x, makeUnique = TRUE, useVectorNames = TRUE, ...)

Arguments

  • x: list of vectors
  • makeUnique: logical indicating whether the data.frame should contain unique rows.
  • useVectorNames: logical indicating whether vector names should be included in the data.frame, if they exist.
  • ...: additional arguments are ignored.

Returns

data.frame with two columns, or three columns when useVectorNames=TRUE and the input x contains names.

Details

This function converts a list of vectors to a tall data.frame with colnames item to indicate the list name, value to indicate the vector value, and name to indicate the vector name if useVectorNames=TRUE and if names exist.

Examples

list2df(list(lower=head(letters, 5), UPPER=head(LETTERS, 10))) list2df(list(lower=nameVector(head(letters, 5)), UPPER=nameVector(head(LETTERS, 10)))) list2df(list(lower=nameVector(head(letters, 5)), UPPER=nameVector(head(LETTERS, 10))), useVectorNames=FALSE)

See Also

Other jam list functions: cPaste(), heads(), jam_rapply(), mergeAllXY(), mixedSorts(), rbindList(), relist_named(), rlengths(), sclass(), sdim(), uniques(), unnestList()

  • Maintainer: James M. Ward
  • License: MIT + file LICENSE
  • Last published: 2025-03-23