Learn R Programming

PivotalR (version 0.1.18.5)

Extract-Replace-methods: Extract or replace a part of '>db.obj objects

Description

Operators acting on '>db.obj objects to extract or replace parts.

Usage

# S4 method for db.obj
$(x, name)
# S4 method for db.obj
[[(x, i, j, ...)
# S4 method for db.obj,ANY,ANY,ANY
[(x, i, j, ..., drop = TRUE)
# S4 method for db.obj,character
$(x, name) <- value
# S4 method for db.obj,integer
$(x, name) <- value
# S4 method for db.obj,numeric
$(x, name) <- value
# S4 method for db.obj,logical
$(x, name) <- value
# S4 method for db.obj,db.Rquery
$(x, name) <- value
# S4 method for db.obj,ANY,ANY,character
[[(x, i, j) <- value
# S4 method for db.obj,ANY,ANY,integer
[[(x, i, j) <- value
# S4 method for db.obj,ANY,ANY,numeric
[[(x, i, j) <- value
# S4 method for db.obj,ANY,ANY,logical
[[(x, i, j) <- value
# S4 method for db.obj,ANY,ANY,db.Rquery
[[(x, i, j) <- value
# S3 method for db.obj
[(x, i, j) <- value


Arguments

x

A db.obj (either db.table, db.view, or db.Rquery) from which to extract element(s).

i, j, ...

Indices specifying elements to extract or replace. Indices are `numeric' or `character' vectors or '>db.Rquery object or empty (missing) or `NULL'.

name

A string. The column name.

value

Any valid value, including '>db.Rquery, character, numeric, integer, and logical object. The value that is used to replace the part of the db.obj.

drop

Not implemented yet.

Value

A db.Rquery object is returned. For the extraction methods, this is a SQL query to extract the requested subset. For the replacement methods, this is a SQL query representing the modified version of x.

See Also

subset,db.obj-method Operator to extract elements

Examples

Run this code
# 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)

x$area <- x[["length"]] * x[,"height"] # add a new column

y <- x[,-c(1,2)] # use all columns except the first two

db.disconnect(cid, verbose = FALSE)
# }

Run the code above in your browser using DataLab