merge {EdSurvey}R Documentation

EdSurvey Merge

Description

Takes a data.frame or a light.edsurvey.data.frame and merges with a light.edsurvey.data.frame.

Usage

## S3 method for class 'light.edsurvey.data.frame'
merge(x, y, ...)

Arguments

x

a light.edsurvey.data.frame. The attributes of the resulting light.edsurvey.data.frame are taken from x.

y

either a light.edsurvey.data.frame or a data.frame

...

arguments to be passed to merge

Value

a light.edsurvey.data.frame with the same attributes as x

Author(s)

Trang Nguyen

See Also

merge

Examples

## Not run: 
# read in NAEP primer data
sdf <- readNAEP(system.file("extdata/data", "M36NT2PM.dat", package = "NAEPprimer"))
lsdf <- getData(data=sdf, varnames=c("dsex", "b017451"), addAttributes = TRUE)
df <- data.frame(dsex = c("Male","Female"), dsex2 = c("Boy","Girl"))

# merging a light.edsurvey.data.frame with a data.frame
# returns a light.edsurvey.data.frame object
merged_lsdf <- merge(lsdf,df, by = "dsex")
class(merged_lsdf) #  "light.edsurvey.data.frame" "data.frame"
head(merged_lsdf) # shows merge results

# merging behaves similarly to base::merge
df2 <- data.frame(dsex = c("Male","Female"), b017451 = c(1,2))
merged_lsdf2 <- merge(lsdf,df2, by = "dsex")
names(merged_lsdf2) # "dsex"      "b017451.x" "b017451.y"
head(merged_lsdf2) # shows merge results

## End(Not run)

[Package EdSurvey version 2.7.1 Index]