Learn R Programming

qdap (version 0.2.5)

Search: Search Columns of a Data Frame

Description

Find terms located in columns of a data frame.

Usage

Search(dataframe, term, column.name = NULL,
    max.distance = 0.02, ...)

Arguments

dataframe
A dataframe object to search.
term
A character vector term to search for.
column.name
Optional column of the data frame to search (character name or integer index).
max.distance
Maximum distance allowed for a match. Expressed either as integer, or as a fraction of the pattern length times the maximal transformation cost (will be replaced by the smallest integer not less than the corresponding fraction).
...
Other arguments passed to agrep.

Value

  • Returns the rows of the data frame that match the search term.

Examples

Run this code
(SampDF <- data.frame("islands"=names(islands)[1:32],mtcars))

Search(SampDF, "Cuba", "islands")
Search(SampDF, "New", "islands")
Search(SampDF, "Ho")
Search(SampDF, "Ho", max.distance = 0)
Search(SampDF, "Axel Heiberg")
Search(SampDF, 19) #too much tolerance in max.distance
Search(SampDF, 19, max.distance = 0)
Search(SampDF, 19, "qsec", max.distance = 0)

Run the code above in your browser using DataLab