rows: Extract rows from a data frame and present as a list

Description Usage Arguments Value Implementation Author(s) Examples

Description

This is a convenience function that takes a dataframe “x” and returns a list where each element is a row of x. I use this for loops.

Usage

1
rows(x)

Arguments

x

A data frame or an object that can be coerced to a data frame.

Value

A list; each element is a row of x.

Implementation

1
2
3
4
5
6
7
8
9
<<*>>=
    rows <- function(x) {
      x <- as.data.frame(x)
      if (nrow(x) > 0) {
        lapply(seq.int(nrow(x)), function(i) x[i,])
      } else {
        list()
      }
    }

Author(s)

Gray Calhoun gcalhoun@iastate.edu

Examples

1
2

grayclhn/dbframe-R-library documentation built on May 17, 2019, 8:33 a.m.