I have subcategorized and categorized labels in excel but I want to make it reproducable so I want to convert it into R code.
I have a df containing 631 rows of which the first 15 rows look like this.
IV_label Subcategory Category
<chr> <chr> <chr>
1 light conditions time of day exogenous
2 vital status victim characteristics human involvement
3 road type road type exogenous
4 reserve density workload police discretion
5 road type road type exogenous
6 surface type road type exogenous
7 surface characteristic road type exogenous
8 light conditions time of day exogenous
9 light conditions time of day exogenous
10 weather weather type exogenous
11 weather weather type exogenous
12 weather weather type exogenous
13 day of the week day of the week exogenous
14 amount of lanes road type exogenous
15 amount of lanes road type exogenous
I want to be able to add the following to my R code without having to construct the lists myself:
time of day <- list(light conditions, ...)
victim characteristics <- list(vital status, ...)
road type <- list(road type, surface type, surface characteristics, amount of lanes, ...) (# notice road type is include only once!)
workload <- list(reserve density, ...)
weather type <- list(weather, ...)
day of the week <- list(day of the week, ...)
exogenous <- list(time of day, road type, weather type, day of the week)
human involvement <- list(victim characteristics)
police discretion <- list(workload)
I understand that I will need to boilerplate this part myself:
time of day <- list(
victim characteristics <- list(
road type <- list(
workload <- list(
weather type <- list(
day of the week <- list(
exogenous <- list(
human involvement <- list(
police discretion <- list(
But I hope to be able to copy the unique values from the console and just past the them into the above boilerplate.