% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/read-openalex.R
\name{read_openalex}
\alias{read_openalex}
\title{Convert OpenAlex data to bibnets format}
\usage{
read_openalex(data)
}
\arguments{
\item{data}{A data frame from \code{oa_fetch(entity = "works", ...)}. Must
contain at least an \code{id} column. Common columns include \code{display_name},
\code{publication_year}, \code{so}, \code{doi}, \code{cited_by_count}, \code{referenced_works},
\code{ab}, and \code{author} (nested).}
}
\value{
A data frame in the standard bibnets format: \code{id}, \code{title},
\code{year}, \code{journal}, \code{doi}, \code{cited_by_count}, \code{abstract}, \code{type},
plus list-columns \code{authors}, \code{references}, and \code{keywords}.
}
\description{
Takes the output of \code{\link[openalexR:oa_fetch]{openalexR::oa_fetch()}} (a tibble/data frame of works)
and converts it to the standardized bibnets format with list-columns.
}
\examples{
# Construct a minimal data frame matching the structure returned by
# openalexR::oa_fetch(entity = "works", ...). In practice, pass the
# result of oa_fetch() directly.
raw <- data.frame(
  id = c("W123", "W456"),
  display_name = c("First paper", "Second paper"),
  publication_year = c(2022L, 2021L),
  so = c("Journal A", "Journal B"),
  doi = c("https://doi.org/10.1/a", "https://doi.org/10.2/b"),
  cited_by_count = c(5L, 12L),
  stringsAsFactors = FALSE
)
raw$author <- list(
  data.frame(au_display_name = c("Smith J", "Jones A"),
             stringsAsFactors = FALSE),
  data.frame(au_display_name = "Davis M", stringsAsFactors = FALSE)
)
raw$referenced_works <- list(c("W100", "W200"), "W123")
data <- read_openalex(raw)
head(data[, c("id", "title", "year", "journal", "doi")])
}
