row_actions: Compute the sum or mean of all columns in one row of a table

Row_actionsR Documentation

Compute the sum or mean of all columns in one row of a table

Description

This function returns a db.Rquery object, which produces the sum or mean value of all columns of one row when executed in database.

Usage

## S4 method for signature 'db.obj'
rowSums(x, na.rm = FALSE, dims = 1, ...)
## S4 method for signature 'db.obj'
rowMeans(x, na.rm = FALSE, dims = 1, ...)

Arguments

x

A db.obj object, which has only one column. The column can be casted into boolean values.

na.rm

logical. Should missing values (including 'NaN') be omitted from the calculations? Not implemented yet.

dims

integer: Which dimensions are regarded as 'rows' or 'columns' to sum over. For 'row*', the sum or mean is over dimensions 'dims+1, ...'; for 'col*' it is over dimensions '1:dims'. Not implemented yet.

...

Other arguments. Not implemented yet.

Value

A db.Rquery object which, when executed, computes the mean or sum of all columns on every row of a table.

Author(s)

Author: Hong Ooi, Pivotal Inc.

Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io

See Also

sum,db.obj-method, colSums,db.obj-method compute the sum of each column.

mean,db.obj-method, colMeans,db.obj-method compute the mean values column-wise.

Examples

 ## Not run: 


## set up the database connection
## Assume that .port is port number and .dbname is the database name
cid <- db.connect(port = .port, dbname = .dbname, verbose = FALSE)

x <- as.db.data.frame(abalone, conn.id = cid, verbose = FALSE)
lk(x, 10)

row.sum <- rowSums(x[,-2]) # the second column is text
row.avg <- rowMeans(x[,-2])

## lokk at 10 results
lk(row.sum, 10)
lk(row.avg, 10)

db.disconnect(cid, verbose = FALSE)

## End(Not run)

greenplum-db/GreenplumR documentation built on Sept. 2, 2023, 8:09 a.m.