with.odbcDataset: Evaluate an R Expression Using Data from an odbcDataset...

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Evaluate an R expression using data from an odbcDataset object, retrieving only the columns used in the expression; the row retrieved may be restricted by specifying an SQL query in the rows argument.

Usage

1
2
## S3 method for class 'odbcDataset'
with(data, expr, rows, ...)

Arguments

data

an odbcDataset object.

expr

an R expression to evaluate.

rows

an optional quoted SQL query to select rows from the dataset.

...

not used.

Details

Perhaps specify some more information

Value

The result of evaluating expr.

Author(s)

John Fox

See Also

odbcDriverConnect, Prestige.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## These examples presuppose that the data set prestige is stored as a table
## in the database attached via odbcDriverConnect().
## This data set is supplied as the data frame Prestige in the dfdb.RODBC
## package.
## Depending upon your OS/DBMS, the call to odbcDriverConnect() may have
## to be modified.

## Not run: 
channel <- odbcDriverConnect()
            
sqlTables(channel)

Prestige <- odbcDataset(channel, "prestige")  # create a pseudo-dataframe
with(Prestige, mean(income))
with(Prestige, mean(income), rows="type = 'prof'")
mod <- with(Prestige, lm(prestige ~ income + education))
summary(mod)
  
## End(Not run)

dfdb.RODBC documentation built on May 2, 2019, 5:18 p.m.