R/listOMLFlows.R

Defines functions .listOMLFlows

.listOMLFlows = function(tag = NULL, limit = NULL, offset = NULL, verbosity = NULL) {
  api.call = generateAPICall("json/flow/list", tag = tag, limit = limit, offset = offset)

  content = doAPICall(api.call = api.call, file = NULL, verbosity = verbosity, method = "GET")
  if (is.null(content)) return(data.table())
  flows = setDT(fromJSON(txt = content)$flows$flow)

  # type conversions
  cols = c("id", "version", "uploader")
  flows[, (cols)  := lapply(.SD, as.integer), .SDcols = cols]
  #flows$tags = vcapply(flows$tags, function(x) collapse(x, ", "))

  setnames(flows, convertNamesOMLToR(names(flows)))
  setnames(flows, stri_replace_all_regex(names(flows), "^id$", "flow.id"))
  flows[]
}

listOMLFlows = memoise(.listOMLFlows)
openml/oml-r documentation built on Aug. 1, 2019, 8:06 p.m.