You have to call in all the packages you will want to use in your analysis using the “library()” code. I have included some code below with the packages i most commonly use and when you might need them.
Note that many functions are built in to R, like ANOVAS, t-tests and regressions, so we dont need to call special programs to be able to run them.
library(readxl) # always import this, you need it to import your data file into R
library(dplyr) # getting the means and standard deviations from your data
library(ggplot2) # plotting any part of your data
library(emmeans) # testing whether an ANOVA interaction is significant
library(mediation) # basic mediation models
library(lavaan) # more complex mediation models and structural equation modelling
library(effectsize) # getting effect sizes for a variety of different statistical tests
library(lme4) # multi-level modelling
library(psych) # makes a bunch of other classic psychology tests like cronbach's alpha and correlations easier to run and interpret
library(reghelper) # simple slopes on a regression interaction
Remember to clear your environment if you have a lot in there. Failing to clear your files can make it harder to find errors in R code if they arise. To clear your environment, click the little broom
How to download the data from qualtrics and get it into R
Download the data from qualtrics.
Before you try to open the data in R, you need to edit it in excel.
b. You have to delete the second row before you can import the file into R
Import the data into R using the code below
# create a new file called "dta" that pulls in the excel file from your computer
dta = read_xlsx("[filepath to the xlsx file on your computer]")