Description Usage Arguments Details Value Author(s) See Also Examples
These operators are used to extract subsets of rows and/or columns of an odbcDataset object.
1 2 3 4 5 6 |
x |
an odbcDataset object. |
i |
for |
j |
columns to select; may be column numbers, negative numbers, or names if missing, all columns are selected. |
drop |
is a single column is selected and |
... |
not used. |
Perhaps some more explanation here.
These operators return a data frame or vector.
John Fox
odbcDataset
, odbcDriverConnect
, Prestige
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## These example 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
Prestige
Prestige[,] # retrieve the whole dataset as a data frame
Prestige$income
Prestige[["income"]]
Prestige["type = 'prof'",] # perform an SQL fetch
Prestige["type = 'prof' order by income", c("education", "income")]
mod <- lm(prestige ~ income + education,
data=Prestige[,c("income", "education", "prestige")])
summary(mod)
remove(Duncan, mod, channel)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.