I have a list obtained through an API:
my_ls <- list(list(hs_legal_basis = list(value = "Freely given consent from contact"),
hs_date_entered_lead = list(value = "1603393304662"), hs_email_last_send_date = list(
value = "1663103935369")), list(hs_legal_basis = list(
value = "Legitimate interest – prospect/lead"), hs_date_entered_lead = list(
value = "1588624274359"), hs_email_last_send_date = list(
value = "1657120876426")), list(hs_legal_basis = list(value = "Freely given consent from contact"),
hs_date_entered_lead = list(value = "1622833942763"), hs_email_last_send_date = list(
value = "1601582035403")))
The awkward thing is that each element has the name of 'value'. When converting to a data frame using bind_rows the column names come through as 'value' in each case.
The column names I want for the actual values are the sublist names - from the above example these would be:
- hs_legal_basis
- hs_date_entered_lead OR
- hs_email_last_send_date
How do I in effect replace the element name of 'value' with the parent sub-list name?
Ideally I'd like to use purrr functions to accomplish this.
Thanks.