diff --git a/R/oa_snowball.R b/R/oa_snowball.R index 117e0a4..8c85a31 100644 --- a/R/oa_snowball.R +++ b/R/oa_snowball.R @@ -36,6 +36,7 @@ oa_snowball <- function(identifier = NULL, ..., id_type = c("short", "original"), + options = list(), mailto = oa_email(), endpoint = "https://api.openalex.org", verbose = FALSE, @@ -45,6 +46,7 @@ oa_snowball <- function(identifier = NULL, base_args <- list( entity = "works", output = "tibble", + options = options, endpoint = endpoint, mailto = mailto, verbose = verbose diff --git a/R/utils.R b/R/utils.R index 8bf4878..16989e6 100644 --- a/R/utils.R +++ b/R/utils.R @@ -14,8 +14,7 @@ replace_w_na <- function(x){ lapply(x, `%||%`, y = NA) } -subs_na <- function(x, type = c("row_df", "col_df", "flat", "rbind_df", "identical"), prefix = NULL) { - type <- match.arg(type) +subs_na <- function(x, type, prefix = NULL) { if (length(x) == 0) { return(NA) } @@ -28,8 +27,7 @@ subs_na <- function(x, type = c("row_df", "col_df", "flat", "rbind_df", "identic row_df = as.data.frame(replace_w_na(x)), col_df = tibble::enframe(unlist(x)), flat = unlist(x), - rbind_df = do.call(rbind.data.frame, lapply(x, replace_w_na) - ) + rbind_df = do.call(rbind.data.frame, lapply(x, replace_w_na)) ) if (!is.null(prefix)) { diff --git a/man/oa_snowball.Rd b/man/oa_snowball.Rd index ceaae95..14db982 100644 --- a/man/oa_snowball.Rd +++ b/man/oa_snowball.Rd @@ -9,6 +9,7 @@ oa_snowball( identifier = NULL, ..., id_type = c("short", "original"), + options = list(), mailto = oa_email(), endpoint = "https://api.openalex.org", verbose = FALSE, @@ -28,6 +29,23 @@ for example, W2755950973. If "original", the OpenAlex IDs are kept as are, for example, https://openalex.org/W2755950973} +\item{options}{List. Additional parameters to add in the query. For example: +- `select` Character vector. Top-level fields to show in output. +Defaults to NULL, which returns all fields. +https://docs.openalex.org/how-to-use-the-api/get-single-entities/select-fields +- `sort` Character. Attribute to sort by. +For example: "display_name" for venues or "cited_by_count:desc" for works. +See more at . +- `sample` Integer. Number of (random) records to return. +Should be no larger than 10,000. +Defaults to NULL, which returns all records satisfying the query. +Read more at . +- `seed` Integer. +A seed value in order to retrieve the same set of random records in +the same order when used multiple times with `sample`. +IMPORTANT NOTE: Depending on your query, random results with a seed value may change over time due to new records coming into OpenAlex. +This argument is likely only useful when queries happen close together (within a day).} + \item{mailto}{Character string. Gives OpenAlex an email to enter the polite pool.}