1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
\name{query}
\alias{query}
\alias{query,data.set-method}
\alias{query,importer-method}
\alias{query,item-method}
\title{Query an Object for Information}
\description{
The function \code{query} can be used to search an object
for a keyword.
The \code{\link{data.set}} and \code{\link{importer}} methods perform such a search
through the annotations and value labels of
the items in the data set.
}
\usage{
query(x,pattern,\dots)
\S4method{query}{data.set}(x,pattern,\dots)
\S4method{query}{importer}(x,pattern,\dots)
\S4method{query}{item}(x,pattern,\dots)
# (Called by the methods above.)
}
\arguments{
\item{x}{an object}
\item{pattern}{a character string that gives the pattern to be searched
for}
\item{\dots}{optional arguments such as
\describe{
\item{\code{fuzzy}}{logical, TRUE by default; use fuzzy search via \code{\link{agrep}} or regexp search
via \code{\link{grep}} }
\item{\code{extended}}{logical, defaults to FALSE; passed to \code{\link{grep}} }
\item{\code{perl}}{logical, defaults to TRUE; passed to \code{\link{grep}} }
\item{\code{fixed}}{logical, defaults to TRUE; passed to \code{\link{grep}} }
\item{\code{ignore.case}}{logical, defaults to TRUE; passed to \code{\link{grep}} or \code{\link{agrep}}}
\item{\code{insertions}}{numerical value, defaults
to 0.999999999; passed to \code{\link{agrep}} }
\item{\code{deletions}}{numerical value, defaults to 0; passed to \code{\link{agrep}} }
\item{\code{substitutions}}{numerical value, defaults to 0; passed to \code{\link{agrep}} }
}
}
}
\value{
If both the annotation and the value labels of an item match the pattern
the \code{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, \code{query} returns \code{NULL}.
The methods of \code{query} for 'data.set' and 'importer' objects return
a list of all non-\code{NULL} query results of all items contained by these
objects, or \code{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")
}
\keyword{manip}
|