Learn R Programming

ibmdbR (version 1.34.3)

ida.data.frame, is.ida.data.frame: Create a IDA data frame

Description

This function creates a 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.

Value

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

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 a 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:
  • Arithmetic operators are +,-,/,*,^
  • Mathematical functions are abs,sqrt,log,log10,exp,floor,round,ceiling
  • Casting functions: as.numeric, as.integer, as.character
  • Comparison and logical operators: <,<=,>,>=,!=,==,!,&,|
  • Conditional functions: ifelse
  • Special functions: is.db.null (checks whether column value is NULL in the table)
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 a ida.data.frame that was defined on columns from another ida.data.frame
  3. You can only add columns that evaluate to non-logical, atomar 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.

Examples

Run this code
systemsBdf <- ida.data.frame('DB2INST1.SHOWCASE_SYSTEMS')
is.ida.data.frame(systemsBdf)

#Select only certain rows or columns
#The following creates a ida.data.frame that only selects rows with
#TYPEID='1' and the first three columns of a table
systemsBdf2 <- systemsBdf[systemsBdf$TYPEID=='1',1:3]

#Alternatively, column names can be specified
systemsBdf2 <- systemsBdf[systemsBdf$TYPEID=='1',c('SID','DESCRIPTION')]

#Define new columns based on existing ones
systemsBdf$TYPEID2 <- systemsBdf$SID+10
systemsBdf$TYPEID3 <- ifelse(systemsBdf$SID==1,systemsBdf$SID,10)

head(systemsBdf)

Run the code above in your browser using DataLab