Indexing SQLiteDataset Objects

Description

Methods for indexing SQLiteDataset Objects. The [ method can take a quoted SQL query as its “row” argument.

Usage

1
2
3
4
5
6
## S3 method for class 'SQLiteDataset'
x[[i]]
## S3 method for class 'SQLiteDataset'
x[i, j, drop = TRUE, ...]
## S3 method for class 'SQLiteDataset'
x$i

Arguments

x

an SQLiteDataset object.

i

for [[ and $, a column name or number; for [, a quoted SQL query to select rows from the data set.

j

a vector of quoted column names or of column numbers.

drop

if TRUE (the default) and only one column is selected, return a vector.

...

ignored.

Value

a data frame or vector.

Note

An empty subscript returns all rows or columns; to select the entire data set, specify dsname[].

Author(s)

John Fox, jfor@mcmaster.ca.

See Also

SQLiteDataset, $

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
dr <- dbDriver("SQLite")
tfile <- tempfile()
con <- dbConnect(dr, dbname = tfile)
dbWriteTable(con, "USArrests", USArrests)
dbDisconnect(con)
Arrests <- SQLiteDataset("USArrests", database=tfile)
Arrests$Murder
Arrests[["Murder"]]
Arrests["Murder > 10", c("Murder", "Rape")]
close(Arrests)