as.data.frame.genderapi: Convert GenderAPI results to a data frame

as.data.frame.genderapiR Documentation

Convert GenderAPI results to a data frame

Description

Flattens a prediction (one row) or a batch (one row per item, in submission order) into a data frame. JSON null becomes NA. confidence is copied unchanged; it is not converted into a percentage or probability. The original list keeps every field, including fields not shown here.

Usage

## S3 method for class 'genderapi_prediction'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

## S3 method for class 'genderapi_batch'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

A genderapi_prediction or genderapi_batch.

row.names, optional

Ignored; present for compatibility with the generic.

...

Ignored.

Details

Columns: index, id, charged_credits (batch only), input_type, input_value, gender, result_status, reason, confidence, confidence_kind, sample_count, source, name, country, country_source, match_name, match_method, match_scope, match_country, and for batches error_status, error_code, error_detail.

Value

A data frame.

Examples

res <- structure(
  list(data = list(gender = NULL, result_status = "unknown",
                   reason = "not_found", confidence = NULL,
                   confidence_kind = NULL, source = "none"),
       meta = list()),
  class = c("genderapi_prediction", "genderapi_response")
)
as.data.frame(res)

genderapi documentation built on Oct. 1, 2026, 5:13 p.m.