Merge ILSA files

knitr::opts_chunk$set(
  collapse = TRUE
)
library(ILSAmerge)

Downloaded data

As an example, we can use the data of 'REDS' 2021 provided by the package.

In the case of 'REDS' 2021, we have 12 files and 3 populations:

ILSAfile.info(inputdir = system.file("extdata/reds", package = "ILSAmerge"))

With ILSAmerge() we can combine all the files into the number of populations we have.

The default type will be an "rds", but also we can make "zsav" and "sav" files:

ILSAmerge(inputdir = system.file("extdata/reds", package = "ILSAmerge"), 
          outputdir = tempdir(), 
          filetype = c("rds", "zsav", "sav"))

Adjust merge options

Depending on your goals or the capabilities of your computer, you may consider adjusting some options of ILSAmerge():

Progress and time for merging

When ILSAmerge() runs, information about the progress of the merging and the running time will be produced:

ILSAmerge(inputdir = system.file("extdata/reds", package = "ILSAmerge"), 
          outputdir = tempdir(), 
          filetype = c("rds", "zsav", "sav"))

Merging between respondents

After merging countries it is also possible to merge datasets of the same or different respondents.

Two functions are available to merge respondents: combineStudents(), and addSchools.

Combine students

combineStudents() combines multiple student files, e.g., achievement and background questionnaires, using 'TIMSS' Advanced 1995:

unlink(file.path(tempdir(),"combineStudents"),recursive = TRUE)
# Path were raw 'SPSS' files are
input <- system.file("extdata/timssadv", package = "ILSAmerge")

# Path were merged files will be saved
dir.create(file.path(tempdir(),"combineStudents"))
output <- file.path(tempdir(),"combineStudents")

# Merging 'TIMSS' Advanced 1995, as .rds file
ILSAmerge(inputdir = input, outputdir = output, filetype = "rds", quiet = TRUE)

# Rename files
ILSArename(output)

# Check file names
list.files(output,pattern = ".rds")

# Combine student files
combineStudents(inputdir = output, outputdir = output)

# Check file names
list.files(output,pattern = ".rds")

As we can see, a new file was created combining the achievement and the student questionnaire.

Combine schools

addSchools() adds school data to student and teacher files, using 'TIMSS' Advanced 1995:

# Check file names
list.files(output,pattern = ".rds")

# Add school data
addSchools(inputdir = output, outputdir = output)

# Check file names
list.files(output,pattern = ".rds")
unlink(file.path(tempdir(),"combineStudents"),recursive = TRUE)

As we can see, a new file was created combining the information of students and schools.



Try the ILSAmerge package in your browser

Any scripts or data that you put into this service are public.

ILSAmerge documentation built on April 11, 2025, 5:54 p.m.