Learn R Programming

PivotalR (version 0.1.18.5)

Row_actions: 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 db.obj
rowSums(x, na.rm = FALSE, dims = 1, ...)
# S4 method for 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.

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

Run this code
# NOT RUN {
 
# }
# NOT RUN {
<!-- %% @test .port Database port number -->
<!-- %% @test .dbname Database name -->
## 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)
# }

Run the code above in your browser using DataLab