Learn R Programming

rowr (version 1.1.3)

rowApply: Applies a function row-wise on any data object.

Description

Essentially functions as a MARGIN=1 apply apply but also works on data objects without 2 dimensions such as lists and vectors.

Usage

rowApply(data, fun, ...)

Arguments

data
any R object
fun
the function to evaluate
...
additional arguments to pass to fun

Examples

Run this code
rowApply(list(1,2,3),function (x) sum(unlist(x)))
df<-data.frame(a=c(1,2,3),b=c(1,2,3))
rowApply(df,sum)

Run the code above in your browser using DataLab