The best way to import SPSS recordsdata into R is to importance the read_sav() serve as from the haven library.
This serve as makes use of refer to modest syntax:
knowledge <- read_sav('C:/Customers/User_Name/file_name.sav')
Refer to step by step instance displays how you can import a SPSS record into R in apply.
Step 1: Obtain a SPSS Record
For this case, we’ll obtain the SPSS record referred to as healthdata.sav from this web page.
Step 2: Set up haven Bundle
Then, we’ll set up the haven bundle in R:
set up.programs('haven')
We’ll upcoming load the bundle:
library(haven)
Step 3: Import the SPSS Record
Then, we’ll importance the read_sav() serve as to import the SPSS record:
knowledge <- read_sav('C:/Customers/bob/Downloads/healthdata.sav')
When we’ve imported the SPSS record, we will be able to get a handy guide a rough abstract of the knowledge:
#view elegance of information
elegance(knowledge)
[1] "tbl_df" "tbl" "data.frame"
#show dimensions of information body
unlit(knowledge)
[1] 185 3
#view first six rows of information
head(knowledge)
CD EXERC HEALTH
1 1 [ordered] 3 6
2 2 [did not order] 3 7
3 2 [did not order] 5 6
4 2 [did not order] 5 3
5 1 [ordered] 5 6
6 2 [did not order] 2 3
We will be able to see that the record imported effectively as an information body and that it has 185 rows and 3 columns.
Alternative Assets
Refer to tutorials give an explanation for how you can import alternative record sorts into R:
Learn how to Import CSV Information into R
Learn how to Import Excel Information into R
Learn how to Import SAS Information into R
Learn how to Import .dta Information into R