Prepare Data"

knitr::opts_chunk$set(
  echo = TRUE # print code
)

Intro

This is a starter file for your "Prepare Data" script. This script should update the data file(s) by re-exporting, merging, re-running calculations, etc. This script should be separate from the "Computational Notebook" file that is used for running analyses on the data. Every time you run the "Computational Notebook" file with the exact same data, you should get the exact same findings (i.e., reproducibility). Thus, we keep the "Prepare Data script" separate from the "Computational Notebook" file so that you update the data only when you intend to.

This document is an R Markdown Notebook, which is an example of a computational notebook. Best practices for using Markdown are in the Lab Wiki here: https://devpsylab.github.io/DataAnalysis/markdown.html#bestPractices. Steps for working with computational notebooks are located in the Lab Wiki here: https://devpsylab.github.io/DataAnalysis/markdown.html#computationalNotebook

Preamble

Install Libraries

#install.packages("remotes")
#remotes::install_github("DevPsyLab/petersenlab")
#remotes::install_github("paulhendricks/anonymizer")

Load Libraries

library("petersenlab") #located here: https://github.com/DevPsyLab/petersenlab

load_or_install(c("tidyverse","anonymizer"))

Set Lab Drive Path

petersenLabPath <- setLabPath()

Update Data

Re-export Data


Import Data


Pre-Merging Preparation

Calculations


Drop Variables


Subset Data


Merge Data


Prepare Data

Calculations


Fill in missing values for SES and demographic variables from other time points


Create Factors


Subset to consented participants


Create Mplus Data

Specify Variables


Save Data


OSF Data

Specify Variables to Keep


Subset Variables


Generate Random Anonymized ID

Generate anonymized ID so that participants cannot be stitched together across papers.


Create Factors


Re-sort Data by Random Anonymized ID

Mix up the order of participants in the data file so they are not in the same order for every paper.


Save Data


Session Info

sessionInfo()

Rstudio Version

rstudioapi::versionInfo()


Try the petersenlab package in your browser

Any scripts or data that you put into this service are public.

petersenlab documentation built on May 29, 2024, 8:34 a.m.