From data to disaggregation to decisions: R Studio set-up

Author

NYU Global TIES for Children

Steps 1 and 2: Create a folder for this workshop and set it as your working R Studio directory

This will make it easier to manage all the various workshop materials. To do so:

  • Create a folder named “D2D-workshop” wherever you would like on your computer.
  • Then, create a folder “data” under that main folder “D2D-workshop”.
  • Save the workshop data in this data sub-folder.
  • You will also want to download the syntaxes for the various days of the workshop and save them in the D2D-workshop main folder.

Now let’s set your working directory in R Studio.

#| label: set working directory

#Find where your working directory is

getwd()

#Change your working directory to the folder where you want to save workshop materials. 
      
setwd("/Users/carolinetubbs/Documents/R Directory/ECW-D2D-workshop")

##note: you will likely have a completely different file path - it may or may not start with "Users" or include your name. Make sure to check and update this file path! 

#Check and make sure your working directory actually changed

getwd()

#Check what you have in the folder:

dir()

##note: this gives you a list of files and folders within your folder, e.g..
## [1] "D2D_descriptive_syntax.qmd"     "D2D_kfa_syntax.html"    "data"

Step 3: Install workshop packages

Once you install a package, you don’t need to install it again on the same computer. If this is your first time using these packages in R Studio, run the following code by:

  • Removing the # in each line below that includes “install.packages()”
  • Highlighting the lines you want to run and press command + Enter (or the “run” button)
#| label: install workshop packages

#Data manipulation and summary statistics
#install.packages("psych")
#install.packages("gtsummary")
#install.packages("dplyr")

#Factor analysis
#install.packages("kfa")
#install.packages("lavaan")

#IRT
#install.packages("mirt")
#install.packages("difR")

#Robust DIF
#install.packages("remotes")

#Plotting
#install.packages("ggplot2")
#remotes::install_github("peterhalpin/robustDIF")