For a project I have a large dataset with a multitude of variables from different questionnaires. Not all variables are required for all analyses.
So I created a preprocessing script, in which subsets of variables (with and without abbreviations) are created. However it gets confusing pretty fast.
For convenience I decided to create a index_list
which holds all data.frames as well as a data.frame called index_df
which holds the name of the respective data.frame as well as a brief description of each subversion of the dataset.
######################## Preparation / Loading #####################
# Clean Out Global Environment
rm(list=ls())
# Detach all unnecessary pacakges
pacman::p_unload()
# Load Required Libraries
pacman::p_load(dplyr, tidyr, gridExtra, conflicted)
# Load Data
#source("00_Preprocess.R")
#create simulation data instead
sub_data <- data.frame(x=c(2,3,5,1,6),y=c(20,30,10,302,5))
uv_newScale <- data.frame(item1=c(2,3,5,1,6),item2=c(3,5,1,3,2))
# Resolving conflicted Namepsaces
conflict_prefer("filter", "dplyr")
# Creating an Index
index_list <- list("sub_data"=sub_data,
"uv_newScale"=uv_newScale
)
index_df <- data.frame("Data.Frame"=c("sub_data",
"uv_newScale"),
"Description"=c("Contains all sumscales + sociodemographics, names abbreviated",
"Only sum scores for the UV Scale"))
I am wondering if there is a more efficient way to do so. Like saving the data.frames together with the description in one container?