# ------------------------------------------------------ # Online Stats Training # Lavaan: how to get started # Exercise 1 - explore data in R # By Rens van de Schoot, Utrecht University # ------------------------------------------------------ # ------------------ # Exercise 1a # ------------------ # Set working directory setwd("C:/Users/ExampleUser/Desktop") # Load package foreign library(foreign) # Import and preview data popular <- read.spss("popular_regr_1.sav", to.data.frame = TRUE) head(popular) # Define missing values popular[popular==-999] <- NA # Define dataset as your working environment attach(popular) # ------------------ # Exercise 1b # ------------------ # Inspect summary statistics summary(popular) # Inspect Boxplot of sd boxplot(sd) # Inspect correlations cor(popular[,(4:6)], use = "pairwise")