UrbanInstitute / education-data-package-r

https://urbaninstitute.github.io/education-data-package-r/
Other
86 stars 11 forks source link

filtering by multiple identification numbers #75

Closed briholt100 closed 3 years ago

briholt100 commented 3 years ago

Hello, I am so thankful for this resource!

I am able to filter by several years, like this:

data <- get_education_data(level = "college-university",
                           source = "ipeds",
                           topic = "finance",
                           filters = list(year=c(2015:2017)))

or

data <- get_education_data(level = "college-university",
                           source = "ipeds",
                           topic = "finance",
                           filters = list(year=2015:2017))

But I am not able to filter by several unitid's with similar syntax:

data <- get_education_data(level = "college-university",
                           source = "ipeds",
                           topic = "finance",
                           filters = list(unitid=c(234669 , 236610 , 236692)))

Am I misunderstanding something or does the API not have this ability? I ask because usually I'm only interested in a few institutions at a time, often not more than 5 or 6 so having to download the whole data set for several years is a bit of a load that I'd like to not abuse.

Thank you for your help and this wonderful tool!

khueyama commented 3 years ago

@briholt100 Thank you for the kind words, and sorry to hear about this issue. I'll need to dive in a bit more to get to the root of this issue, but in the mean time you could do something like:

library(dplyr)
library(educationdata)

unitids <- c(234669 , 236610 , 236692)

data <- bind_rows(
  lapply(unitids, function(x){
    get_education_data(level = "college-university",
                       source = "ipeds",
                       topic = "finance",
                       filters = list(unitid = x))
    })
  )

Which is not as clean and easy as it should be, but will save you the time and hassle of pulling everything. And we certainly appreciate your conscientiousness on API load! I'll let you know as soon as I have a real fix in place.

briholt100 commented 3 years ago

Oh, so doing multiple calls is Ok? I learned about some API's long ago and have since forgotten most things; I just remember to be kind with multiple calls or heavy use in general.

Thank you so much for the quick response and the example code!

khueyama commented 3 years ago

@briholt100 Just to close the loop on this - our API team has figured out the issue with comma separated filters, and the fix will be part of the next release. And yes for the time being I think that example code would work best since you're querying for such a small subset of unitids. Please don't hesitate to let me know if you run into any other issues!