# ---------------------------- # # R: how to get started # # 11/09/2017 # # Lion Behrens # # ---------------------------- # # --------------- # Exercise 1 # --------------- # Set working directory setwd("C:/Users/User/Desktop") # Load in data library(foreign) popular <- read.spss("popular_regr_1.sav", to.data.frame = TRUE) # Inspect and prepare data head(popular) popular[popular==-999] <- NA attach(popular) summary(popular) boxplot(sw) # Compute pairwise correlations cor(popular[,(4:6)], use = "pairwise") # ---------------- # Exercise 2 # ---------------- # Fit linear regression model model <- 'sw ~ overt + covert' fit <- lm(model, data = popular) # Inspect regression output summary(fit)