Import SPSS data with haven
The haven
package can also import data files from SPSS. Again, importing the data is pretty straightforward. Depending on the SPSS data file you're working with, you'll need either read_sav()
- for .sav
files - or read_por()
- for .por
files.
In this exercise, you will work with data on four of the Big Five personality traits for 434 persons (Source: University of Bath). The Big Five is a psychological concept including, originally, five dimensions of personality to classify human personality. The SPSS dataset is called person.sav
and is available in your working directory.
Cet exercice fait partie du cours
Intermediate Importing Data in R
Instructions
- Use
read_sav()
to import the SPSS data in"person.sav"
. Name the imported data frametraits
. traits
contains several missing values, orNA
s. Runsummary()
on it to find out how manyNA
s are contained in each variable.- Print out a subset of those individuals that scored high on Extroversion and on Agreeableness, i.e. scoring higher than 40 on each of these two categories. You can use
subset()
for this.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# haven is already loaded
# Import person.sav: traits
# Summarize traits
# Print out a subset