as.db.data.frame | R Documentation |
db.data.frame
object
Methods for function as.db.data.frame
in package
GreenplumR. When x
is a file name or data.frame
, the
method puts the data into a table in the database. When x
is a
db.Rquery
object, it is converted into a
table. When x
is a db.data.frame
object, a
copy of the table/view that x
points to is created.
## S4 method for signature 'character'
as.db.data.frame(x, table.name = NULL,
verbose = TRUE, conn.id = 1, add.row.names = FALSE, key = character(0),
distributed.by = NULL, append = FALSE, is.temp = FALSE, ...)
## S4 method for signature 'data.frame'
as.db.data.frame(x, table.name = NULL, verbose =
TRUE, conn.id = 1, add.row.names = FALSE, key = character(0),
distributed.by = NULL, append = FALSE, is.temp = FALSE, ...)
## S4 method for signature 'db.Rquery'
as.db.data.frame(x, table.name = NULL, verbose =
TRUE, is.view = FALSE, is.temp = FALSE, pivot = TRUE, distributed.by =
NULL, nrow = NULL, field.types = NULL, na.as.level = FALSE,
factor.full = rep(FALSE, length(names(x))))
## S4 method for signature 'db.data.frame'
as.db.data.frame(x, table.name = NULL, verbose
= TRUE, is.view = FALSE, is.temp = FALSE, distributed.by = NULL, nrow =
NULL, field.types = NULL)
as.db.Rview(x)
x |
The signature of this method. When it is of type When it is of type When it is of type For |
table.name |
A string, the name of the table to be created. The returned
|
verbose |
A logical, default is |
conn.id |
An integer, default is 1. The ID of the connection. See
|
add.row.names |
A logical, default is |
key |
A string, default is |
distributed.by |
A string, default is |
append |
A logical, default is |
nrow |
An integer, default is |
is.temp |
A logical, default is |
... |
Extra parameters used to create the table inside the database. We
support the following parameters:
|
is.view |
A logical, default is |
pivot |
A logical, default is |
na.as.level |
A logical value, default is |
field.types |
A list of |
factor.full |
A vector of logical values with the length of the column number. All |
A db.data.frame
object. It points to a table whose name is
given by table.name
in connection conn.id
.
All the as.db.data.frame
accept the option field.types
.
Author: Predictive Analytics Team at Pivotal Inc.
Maintainer: Frank McQuillan, Pivotal Inc. fmcquillan@pivotal.io
[1] Greenplum database, http://www.greenplum.org
db.data.frame
creates an object pointing to a table/view
in the database.
lk
looks at data from the table
db.Rquery
this type of object represents
operations on an existing db.data.frame
object.
## Not run:
## get the help for a method
## help("as.db.data.frame")
## help("as.db.data.frame,db.Rquery-method")
## 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)
## create a table from the example data.frame "abalone"
x <- as.db.data.frame(abalone, conn.id = cid, verbose = FALSE)
## preview of a table
lk(x, nrows = 10) # extract 10 rows of data
## do some operations and preview the result
y <- (x[,-2] + 1.2) * 2
lk(y, 20, FALSE)
## table abalone has a column named "id"
lk(sort(x, INDICES = x$id), 20) # the preview is ordered by "id" value
## create a copied table
## x[,] converts x from db.data.frame object to db.Rquery object
z <- as.db.data.frame(x[,])
## Force the data type, use random table name
z1 <- as.db.data.frame(x$rings, field.types = list(rings="integer"))
db.disconnect(cid, verbose = FALSE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.