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

Description Usage Arguments Value Author(s) See Also Examples

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

1
2
3
4
## 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 ## 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)

PivotalR documentation built on March 13, 2021, 1:06 a.m.