I have a number of lists of lists, and in each of them the variable I need to extract is nested in a slightly different way. Is there a simple way to search for the variable and to extract it?
Example lists
list1 <- list(AccountingSupplierParty = list(Party = list(PartyName = "Company Incorporated", PartyType = "The worst party")), DataSet = "Data Set 1")
list2 <- list(SupplierParty = list(Party = list(PartyName = "Company A/S", PartyType = "The best party")), DataSet = "Data Set 2")
I would like to extract "PartyName". It is not so efficient to learn all combinations of variables in a huge dataset as illustrated underneath:
Company1 <- list1$AccountingSupplierParty$Party$PartyName
Company2 <- list2$SupplierParty$Party$PartyName
The output I would like is:
"Company Incorporated"
"Company A/S"