Closed daxkellie closed 2 years ago
After discussion, we have noticed that this issue could be solved by optimising the group_by
argument in ala_counts()
for multiple arguments. This might be a better solution than changing the behaviour of select_filters()
/cc @mjwestgate
galah_group_by
function accepts multiple arguments and prevents the need for looping to achieve the same results as above
select_filters()
can be used to filter queries to the API, and is a central part of theala_
group of functions. However, when trying to run more complex loops to group specific taxa, filters and categories,select_filters()
can cause issues.For example, say I want to extract counts of occurrence records by year using
ala_counts()
. We can create a filter to extract a sequence of years from 1999 to 2003. Notice thatselect_filters()
creates adata.frame
to build a queryNow let's try adding the sequence of years to an object
This doesn't seem to work.
Building full request using
paste0()
doesn't work eitherThis limitation to
select_filters()
becomes a problem when wanting to run more complex loops with functions likeala_counts()
. If I want to get counts of occurrence records by kingdom and by year, I can run a loop usingpurrr::map()
like soNice! But I can't use the same technique I used above with
select_taxa()
to loop withinselect_filters()
. For example, say I want to get the counts of observations from different data providers by yearNo dice
Building the full argument including the
select_filters()
call, however, does workBut what if I want to extract counts by kingdoms and by year, and then group by a third category (in this case data providers)?
Yet again, no dice.
Notice that the error suggests that the filters are not in data frame. It seems that when looped in this way,
select_filters()
cannot create each querydata.frame
and fails