bydf {scsR} | R Documentation

## bydf

### Description

apply a function to a group of rows in the input data frame (similar to the sql group by statememnt).

### Usage

    bydf(df, groupColName, valColName, fun, newColName="temp_by_col_name")

    bydfa(df, groupColName, valColName, fun, newColName="temp_by_col_name")

### Arguments

`df` | input data frame
`groupColName` | name of the column to be used for grouping the rows (character vector)
`valColName` | name of the column containing the values to be inserted in the function (character vector)
`fun` | function to be applied (function)
`newColName` | name of the colum that contains the result of the function (character vector)

### Details

The methods currently depend on the type of `to`:

bydf

  apply a function to a group of rows in the input data frame (similar to the sql group by statememnt). Put the results of this function in a new data frame that is returned as output.

bydfa

  apply a function to a group of rows in the input data frame (similar to the sql group by statememnt). return the same data frame with an additional column with the results of the function.

### Value

bydf: data frame with the function applied to the grouping bydfa: input data frame with an additional column with the results of the function applied to the grouping.

### Author(s)

Andrea Franceschini

### Examples

    	data(uuk_screen)
    	screen=add_seed(uuk_screen[1:1000,])
    	screen_sd = bydf(screen, groupColName="seed7", "score", sd, "sd")

[Package scsR version 1.18.0 Index]