USEPA / ccdR

Predecessor to ctxR. Utilities for Interacting with the CTX APIs in R without prior API knowledge. All data is also available on the CompTox Chemical Dashboard (CCD) https://comptox.epa.gov/dashboard/
https://github.com/USEPA/ctxR
GNU General Public License v3.0
2 stars 0 forks source link

Bioactivity APIs are inconsistent whether they return a list or a table #6

Closed cthunes closed 6 months ago

cthunes commented 6 months ago

I'm assuming the preference is to return tables. The two that return as lists currently likely contain non-length 1 (NULL or a length > 1) list items, which I assume is why it wasn't automatically converted to a table. The functions may need to handle the fixes with something like the following:

for (i in 1:length(res)) { 
  if (is.null(res[[i]])) res[[i]] <- NA # set any NULLs to NA
  if (length(res[[i]]) > 1) { 
    res[[i]] <- list(res[[i]]) # put lengths > 1 into a list to be just length 1, will unnest after
  }
}
res_dt <- tibble::as_tibble_row(res)