Extract subsets of a ml.data.frame

Share:

Description

Extract subset of columns and/or rows of a ml.data.frame. When extracting rows a ml.col.def referense can be used or a search text, see ml.data.frame for query string grammar. See details for limitations when using a reference. The row filtering will be used togheter with the existing query of the ml.data.frame

Usage

1
2
## S4 method for signature 'ml.data.frame'
x[i, j, ..., drop = NA]

Arguments

x

a ml.data.frame from which to extract element(s).

i, j

Indices specifying elements to extract. Indices are 'numeric' or 'character' vectors or empty (missing) or 'NULL'.

...

Not used.

drop

Not used.

Details

When extracting rows using ml.col.def comparison operators can be used. For the ">" "<" "!=" "<=" ">=" operators there muset exist a element range index on the source field or a error will be raised, element range index can be created using the ml.add.index function. "==" operator will always work since it does not depend of range indexes.

Value

A ml.data.frame object is returned

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 
 library(rfml)
 localConn <- ml.connect()
 # create a ml.data.frame based on the iris data set
 mlIris <- as.ml.data.frame(localConn, iris, "iris")
 # select first three columns
 mlIris2 <- mlIris[1:3]
 # same
 mlIris2 <- mlIris[,1:3]
 # same
 mlIris2 <- mlIris[,c("Sepal.Length","Sepal.Width","Petal.Length")]
 # select first three columns for all rows with Spieces = setosa
 mlIris2 <- mlIris[mlIris$Species=="setosa", 1:3]
 # select all columns for all rows with Spieces = setosa
 mlIris2 <- mlIris[mlIris$Species=="setosa",]
 # select all columns for all rows with "setosa" in any column
 mlIris2 <- mlIris["setosa",]

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.