Answer: SPSS datasets can be imported into R via the read.spss() function in the foreign package . Also, we can use the spss.get() function in the Hmisc package.
spss.get() is a wrapper function that automatically sets many parameters of read.
First, download and install the Hmisc package .
install.packages("Hmisc")
Then use the following code to import the data:
library(Hmisc)
mydataframe <- spss.get("mydata.sav", use.value.labels=TRUE)
In this code, mydata.sav is the SPSS data file to be imported, use.value.labels=TRUE tells the function to convert variables with value labels into R factors
with those same levels, and mydataframe is the resulting R data frame.
Asked In: Many Interviews |
Alert Moderator