iDigBio / ridigbio

ridigbio -- an R interface to iDigBio's API (see http://www.idigbio.org/)
http://idigbio.github.io/ridigbio/
Other
16 stars 10 forks source link

WIP: refactor to use dplyr #36

Open fmichonneau opened 7 years ago

fmichonneau commented 7 years ago

I'm following up on @adamdsmith's suggestion of using dplyr instead of plyr to build the data frame.

This works and passes the tests for the record search. However, it fails (and crashes R) for media searches.

This is in part caused by the wonky format of the current result (data frame that contains lists) for media searches. From a quick glance, it seems that maybe the field names have changed, and we need new code to ensure that fmt_search_txt_to_df returns a flat data frame.

mjcollin commented 7 years ago

I made a change to deal with the new "indexData" field that got added to API responses around September. I think this is the origin of @adamsmith's original issue. However, I went to test this PR and I now get:

Error in[[<-.data.frame(tmp, i, value = list(country = c("united states", : replacement has 5000 rows, data has 0

when running either of the idigsearch* functions. Could you test/retest?

fmichonneau commented 7 years ago

Which request are you trying?

If I do:

idig_search_records(rq = list(genus = "Holothuria"))

I don't see the warning

but

idig_search_media(rq = list(genus = "Holothuria"))

still crashes R because the dat object after the while loop isn't a 2 dimensional data frame (some of the columns contain themselves data frame).

I can easily modify fmt_search_txt_to_df to return a 2d data frame, but I'm not sure all the information this contains is needed.

mjcollin commented 7 years ago

Still havent' returned to this but pushing out a new release to address the issue in PR #35 since others are probably having that.

Still holding open...