2

Using expss package I am creating cross tabs by reading SPSS files in R. This actually works perfectly but the process takes lots of time to load. I have a folder which contains various SPSS files(usually 3 files only) and through R script I am fetching the last modified file among the three.

setwd('/file/path/for/this/file/SPSS')

library(expss)

expss_output_viewer()

#get all .sav files
all_sav <- list.files(pattern ='\\.sav$')
#use file.info to get the index of the file most recently modified
pass<-all_sav[with(file.info(all_sav), which.max(mtime))]


mydata = read_spss(pass,reencode = TRUE)  # read SPSS file  mydata 
w <- data.frame(mydata)
args <- commandArgs(TRUE)


Everything is perfect and works absolutely fine but it generally takes too much time to load large files(112MB,48MB for e.g) which isn't good.

Is there a way I can make it more time-efficient and takes less time to create the table. The dropdowns are created using PHP.

I have searched for this and found another library called 'haven' but I am not sure whether that can give me significance as well. Can anyone help me with this? I would really appreciate that. Thanks in advance.

1 Answers1

0

As written in the expss vignette (https://cran.r-project.org/web/packages/expss/vignettes/labels-support.html) you can use in the following way:

# we need to load packages strictly in this order to avoid conflicts
library(haven)
library(expss)
spss_data = haven::read_spss("spss_file.sav")
# add missing 'labelled' class
spss_data = add_labelled_class(spss_data) 
Gregory Demin
  • 4,596
  • 2
  • 20
  • 20
  • Can you help me with the multiple select questions (mrset) on how to read SPSS files for multiple select questions in R for cross tabs? I have been trying this for so many days but was not able to find a solution for it. Please see if you can help me with this, Would be greatly appreciated. Thanks in advance – Shubham Prabhakar Oct 16 '19 at 16:41