searchSDF: EdSurvey Codebook Search

View source: R/searchSDF.R

searchSDFR Documentation

EdSurvey Codebook Search

Description

Retrieves variable names and labels for an edsurvey.data.frame, a light.edsurvey.data.frame, or an edsurvey.data.frame.list using character string matching.

Usage

searchSDF(string, data, fileFormat = NULL, levels = FALSE)

Arguments

string

a vector of character strings to search for in the database connection object (data). The function will search the codebook for a matching character string using regular expressions. When a string has several elements, all must be present for a variable to be returned.

data

an edsurvey.data.frame, a light.edsurvey.data.frame, or an edsurvey.data.frame.list

fileFormat

a character vector indicating the data source to search for variables. The default NULL argument searches all codebooks.

levels

a logical value; set to TRUE to return a snapshot of the levels in an edsurvey.data.frame

Value

a data.frame that shows the variable names, labels, and levels (if applicable) from an edsurvey.data.frame or a light.edsurvey.data.frame based on a matching character string

Author(s)

Michael Lee and Paul Bailey

Examples

## Not run: 
# read in the example data (generated, not real student data)
sdf <- readNAEP(path=system.file("extdata/data", "M36NT2PM.dat", package="NAEPprimer"))

# search both the student and school files by a character string
searchSDF(string="book", data=sdf)

# use the `|` (OR) operator to search several strings simultaneously
searchSDF(string="book|home|value", data=sdf)

# use a vector of strings to search for variables that contain multiple strings,
# such as both "book" and "home"
searchSDF(string=c("book","home"), data=sdf)

# search only the student files by a character string
searchSDF(string="algebra", data=sdf, fileFormat="student")

# search both the student and school files and return a glimpse of levels
searchSDF(string="value", data=sdf, levels=TRUE)

# save the search as an object to return a full data.frame of search
ddf <- searchSDF(string="value", data=sdf, levels=TRUE)
ddf

## End(Not run)

EdSurvey documentation built on June 27, 2024, 5:10 p.m.