Skip to contents

oa_fetch but for a random query

Usage

oa_random(
  entity = oa_entities(),
  output = c("tibble", "dataframe", "list"),
  endpoint = "https://api.openalex.org"
)

Arguments

entity

Character. Scholarly entity of the search. The argument can be one of c("works", "authors", "institutions", "keywords", "funders", "sources", "publishers", "topics"). If not provided, `entity` is guessed from `identifier`.

output

Character. Type of output, one of `"tibble"`, `"dataframe"`, `"list"`, or `"raw"`.

  • "tibble": a tibble tidy data

  • "dataframe": a base data.frame tidy data

  • "list": a list of parsed JSON contents

  • "raw": a list of raw JSON strings (length depends on query)

endpoint

Character. URL of the OpenAlex Endpoint API server. Defaults to endpoint = "https://api.openalex.org".

Value

A data.frame or a list. One row or one element. Result of the random query. If you would like to select more than one random entity, say, 10, use `options = list(sample = 10)` argument in `oa_fetch`.

Examples

oa_random()
#> Warning: Note: `oa_fetch` and `oa2df` now return new names for some columns in openalexR v2.0.0.
#>     See NEWS.md for the list of changes.
#>     Call `get_coverage()` to view the all updated columns and their original names in OpenAlex.
#> This warning is displayed once every 8 hours.
#> # A tibble: 1 × 40
#>   id              title display_name authorships abstract doi   publication_date
#>   <chr>           <chr> <chr>        <list>      <chr>    <chr> <date>          
#> 1 https://openal… Fami… Family and … <tibble>    Introdu… http… 1999-06-01      
#> # ℹ 33 more variables: publication_year <int>, fwci <dbl>,
#> #   cited_by_count <int>, counts_by_year <list>, cited_by_api_url <chr>,
#> #   ids <list>, type <chr>, is_oa <lgl>, is_oa_anywhere <lgl>, oa_status <chr>,
#> #   oa_url <lgl>, any_repository_has_fulltext <lgl>, source_display_name <chr>,
#> #   source_id <chr>, issn_l <chr>, host_organization <chr>,
#> #   host_organization_name <chr>, landing_page_url <chr>,
#> #   referenced_works <lgl>, referenced_works_count <int>, …