Learn R Programming

sos (version 2.1-8)

Extract.findFn: Subset a findFn object

Description

Extract rows from a findFn object

Usage

# S3 method for findFn
[(x, i, j,
    drop = 
    if (missing(i)) TRUE else length(j) == 1)

Value

If j is missing, return an object of class

c('findFn', 'data.frame') else return whatever is returned by Extract.data.frame.

Arguments

x

An object of class findFn

i

a valid object to select rows of x, e.g., a vector of all positive integers or all negative integers between 1 and nrow(x) or a logical vector of length nrow(x).

j

If not missing, the extraction function returns an object of class data.frame rather than findFn.

drop

logical: if FALSE and j selects only one column, return that column as a vector; else return a data.frame if j is present or a findFn object otherwise.

Author

Spencer Graves

Details

1. if(missing(j)) extract the subset with the PackageSummary attribute recomputed on the subset.

2. else return(Extract.data.frame(x, i, j, drop))

See Also

findFn, data.frame

Examples

Run this code
  z <- try(findFn("spline", maxPages = 2))
  
  if(!inherits(z, "try-error")){
# one row
  z1 <- z[1,]

# one column 
  z.2 <- z[, 2]
# 
  z.2a <- z[2]
  stopifnot(
    all.equal(z.2, z.2a)
  )
# data.frame with one column
  z.2d <- z[, 2, drop=FALSE]
  }

Run the code above in your browser using DataLab