Fingertips R multiple indicator areatypes

Using the fingertips package, I would like to pull data into R for a list of indicator IDs. These indicators have different AreatypeIDs (e.g. some are at the CCG level, some at the Upper tier local authority level etc.)
I have constructed the following function to pull the data into a dataframe in R:

df <- fingertips_data(IndicatorID = ind_list, AreaTypeID = area_id_list$AreaTypeID, ParentAreaTypeID = area_id_list$ParentAreaTypeID)

where ind_list is a vector of indicator IDs, area_id_list is a dataframe containing the relevant AreaTypeIDs and ParentAreaTypeID for each of the indicators in the ind_list vector.

The ind_list vector and area_id_list dataframe both have the same number of values/rows.

When I run this code I get the following error:
Error: ! Tibble columns must have compatible sizes. Size 49: Existing data. Size 3: Column ParentAreaTypeIDs. i Only values of size one are recycled. Run rlang::last_error() to see where the error occurred. Warning messages: 1: In if (AreaTypeID == "All") { : the condition has length > 1 and only the first element will be used 2: In if (AreaTypeID == "All") { : the condition has length > 1 and only the first element will be used

Is there a way to run the fingertips_data function for multiple indicators with a variety of AreaTypeIDs? Or is it only possible to run it for multiple indicators with the same AreaTypeID?

HI @anthony.veal - it looks like the functions off the shelf don’t work for how you want to use them. You should be able to combine them with some purrr functions to achieve what you want:

IndicatorIDs <- list(108, 114)
AreaTypeIDs <- list(402, 219)
ParentAreaTypeIDs <- list(6, 15)

df <- purrr::pmap_dfr(
  .l = list(
    IndicatorID = IndicatorIDs,
    AreaTypeID = AreaTypeIDs,
    ParentAreaTypeID = ParentAreaTypeIDs
  .f = fingertipsR::fingertips_data

df |> 

I hope this helps