Learn R Programming

EdSurvey (version 1.0.6)

searchSDF: Search and print out a summary of variable information on an edsurvey.data.frame or light.edsurvey.data.frame.

Description

searchSDF returns a data.frame that shows the variable names and labels from an edsurvey.data.frame or light.edsurvey.data.frame. The function will search both student and school data sets for a matching character string in embedded file format.

Usage

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

Arguments

string

character string to search for in the database connection object (data). Note that the function will search both the student and school datasets for a matching character string in embedded file format.

data

object of class edsurvey.data.frame (see readNAEP for how to generate an edsurvey.data.frame).

fileFormat

character string indicating the file type to search for variables. The default NULL argument searches both the student and school files. If the string value isn't “school” or “student”, the function will return an error message indicating an empty match.

levels

logical. 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 light.edsurvey.data.frame based on a matching character string.

Examples

Run this code
# NOT RUN {
# read in the example data (generated, not real student data)
sdf <- readNAEP(system.file("extdata/data", "M36NT2PM.dat", package = "NAEPprimer"))

# search both the student and school files by a character string
searchSDF(string="book", 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
# }

Run the code above in your browser using DataLab