I have a list with the following structure:
l <- list(condition = "AND",
rules = list(list(id = "sex",
field = "sex"),
list(condition = "AND",
rules = list(
list(id = "species",
field = "species"),
list(condition = "AND",
rules = list(
list(id = "bill_length_mm",
field = "bill_length_mm")))))),
valid = TRUE)
and I would like to convert to this structure
goal <- list(
list(id = "sex",
field = "sex"),
list(id = "species",
field = "species"),
list(id = "bill_length_mm",
field = "bill_length_mm")
)
The solution would need to be flexible enough to handle more/less rules elements. Any suggestions on how I can do this would be greatly appreciated!