ida.data.frame, is.ida.data.frame {ibmdbR}R Documentation

Create an IDA data frame

Description

This function creates an IDA data frame (that is, an object of the class ida.data.frame). It does not store any data in local memory, but aggregates metadata used to determine the exact table subset (columns - SELECT clause; and/or rows - WHERE clause) and creates a pointer to a table located in the database.

Usage

ida.data.frame(table)
is.ida.data.frame(x)

Arguments

table

Name of a table or view in the current database.

x

An ida.data.frame object.

Details

The argument table must be a valid table or view name and the table/view must exist.

If schema or table are set in quotes, they will be treated case sensitive otherwise they are automatically converted to the default schema of the database. Columns are always treated case sensitive.

A subset of columns and/or rows may be specified using the indexing operator [] (which is translated to the SELECT clause for columns and/or the WHERE clause for rows). Note that columns are treated case sensitive.

One limitation is that rows cannot be selected using their numbers. Instead, you must specify value-based conditions, for example d[d$ID > 10,] which means “all rows where the value of the first column is greater than 10”. The $ operator may be also used to select an ida.data.frame column.

You can also add and alter columns in an ida.data.frame. Currently, a limited set of functions and operators is supported to define columns based on other columns. The following is supported:

There are several rules for adding columns:

  1. You can not combine columns from different tables or from ida.data.frames that have different WHERE conditions.

  2. You cannot add a column to an ida.data.frame that was defined on columns from another ida.data.frame

  3. You can only add columns that evaluate to non-logical, atomic values

The package does basic type checking to enforce these rules, however, it is still possible that the database will refuse a query that was not properly defined.

is.ida.data.frame checks if the given object's class is ida.data.frame.

Value

ida.data.frame returns an IDA data frame.

is.ida.data.frame returns a logical value that indicates whether the specified object is an IDA data frame.

Examples

## Not run: 
idf <- ida.data.frame('IRIS')
is.ida.data.frame(idf)

#Select only certain rows or columns
#The following creates an ida.data.frame that only selects rows with
#Species=='setosa' and the first three columns of the table
idf2 <- idf[idf$Species=='setosa',1:3]

#Define new columns based on existing ones
idf$SepalLengthX <- idf$SepalLength+1
idf$SepalLengthY <- ifelse(idf$SepalLengthX>4.5,idf$ID,10)

#Take a look at the newly defined columns
head(idf)

 

## End(Not run)

[Package ibmdbR version 1.51.0 Index]