Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

query

Query an Object for Information


Description

The function query can be used to search an object for a keyword.

The data.set and importer methods perform such a search through the annotations and value labels of the items in the data set.

Usage

query(x,pattern,...)
## S4 method for signature 'data.set'
query(x,pattern,...)
## S4 method for signature 'importer'
query(x,pattern,...)

## S4 method for signature 'item'
query(x,pattern,...)
# (Called by the methods above.)

Arguments

x

an object

pattern

a character string that gives the pattern to be searched for

...

optional arguments such as

fuzzy

logical, TRUE by default; use fuzzy search via agrep or regexp search via grep

extended

logical, defaults to FALSE; passed to grep

perl

logical, defaults to TRUE; passed to grep

fixed

logical, defaults to TRUE; passed to grep

ignore.case

logical, defaults to TRUE; passed to grep or agrep

insertions

numerical value, defaults to 0.999999999; passed to agrep

deletions

numerical value, defaults to 0; passed to agrep

substitutions

numerical value, defaults to 0; passed to agrep

Value

If both the annotation and the value labels of an item match the pattern the query method for 'item' objects returns a list containing the annotation and the value labels, otherwise if only the annotation or the value labels match the pattern, either the annotation or the value labels are returned, otherwise if neither matches the pattern, query returns NULL.

The methods of query for 'data.set' and 'importer' objects return a list of all non-NULL query results of all items contained by these objects, or NULL.

Examples

nes1948.por <- unzip(system.file("anes/NES1948.ZIP",package="memisc"),
                     "NES1948.POR",exdir=tempfile())
nes1948 <- spss.portable.file(nes1948.por)
query(nes1948,"TRUMAN")

memisc

Management of Survey Data and Presentation of Analysis Results

v0.99.27.3
GPL-2
Authors
Martin Elff (with contributions from Christopher N. Lawrence, Dave Atkins, Jason W. Morgan, Achim Zeileis)
Initial release
2020-11-18

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.