Title: | A Reference Manager |
---|---|
Description: | 'Cristin' to 'Zotero' ('c2z') aims at obtaining total dominion over 'Cristin' ('Current Research Information SysTem in Norway') and 'Zotero'. The package enables manipulating 'Zotero' libraries using 'R'. Import references from 'Cristin', 'Regjeringen', 'CRAN', 'ISBN' ('Alma', 'LoC'), and 'DOI' ('CrossRef', 'DataCite') to a 'Zotero' library. Add, edit, copy, or delete items, including attachments and collections, and export references to 'BibLaTeX' (and other formats). |
Authors: | Øystein Olav Skaar [aut, cre, cph]
|
Maintainer: | Øystein Olav Skaar <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0.9007 |
Built: | 2025-03-13 15:21:02 UTC |
Source: | https://github.com/oeysan/c2z |
This function checks if the input url
contains a valid Digital Object
Identifier (DOI) using a regular expression.
If a valid DOI is found, it extracts the DOI and optionally returns either
the DOI string or the full DOI URL.
CheckDoi(url, doi.only = FALSE)
CheckDoi(url, doi.only = FALSE)
url |
A character string representing a URL or a DOI-containing text. |
doi.only |
Logical; if |
The function uses a regular expression to search for a DOI in the
input. It leverages an external function
GoFish
(with type = FALSE
) to perform additional checks.
The DOI is then trimmed using a function called
Trim
. The regular expression pattern is designed to match the
standard DOI format.
Returns a character string with the DOI (or full DOI URL) if found;
otherwise, returns NULL
.
## Not run: # Example 1: Extract full DOI URL from a string containing a DOI doi_url <- CheckDoi("https://doi.org/10.1000/xyz123") # doi_url will be "https://doi.org/10.1000/xyz123" # Example 2: Extract only the DOI without the URL prefix doi_only <- CheckDoi("10.1000/xyz123", doi.only = TRUE) # doi_only will be "10.1000/xyz123" ## End(Not run)
## Not run: # Example 1: Extract full DOI URL from a string containing a DOI doi_url <- CheckDoi("https://doi.org/10.1000/xyz123") # doi_url will be "https://doi.org/10.1000/xyz123" # Example 2: Extract only the DOI without the URL prefix doi_only <- CheckDoi("10.1000/xyz123", doi.only = TRUE) # doi_only will be "10.1000/xyz123" ## End(Not run)
This function takes an input string that may contain an ISBN (or a compound string
where the first component is the ISBN), cleans it by removing non-alphanumeric characters
(except spaces) and spaces, and processes it with the GoFish
function. If the cleaned
ISBN is in the ISBN10 format, the function converts it to ISBN13. Finally, it validates the ISBN;
valid ISBNs either start with "97" and are 13 characters long or start with "99" and are longer than 7 characters.
CheckIsbn(key, split.key = ",")
CheckIsbn(key, split.key = ",")
key |
A character string that contains an ISBN or a compound string where the first element is the ISBN. |
split.key |
A delimiter used to split the |
The function performs the following steps:
Splits the input key
using split.key
and selects the first element.
Removes foreign (non-alphanumeric) characters and spaces using nested gsub
calls.
Applies the GoFish
function to the cleaned key (ensure that GoFish
is defined in your environment).
If the key is in ISBN10 format (10 characters), converts it to ISBN13 by prepending 978
,
recalculating the check digit, and concatenating the result.
Checks that the final key is valid by confirming that it either starts with "97" (and is 13 characters long) or starts with "99" and has more than 7 characters.
A cleaned and validated ISBN string. If the resulting ISBN does not meet the expected criteria,
the function returns NULL
.
## Not run: # Example with a compound string where the first part is the ISBN: isbn_input <- "316148410X, some extra text" valid_isbn <- CheckIsbn(isbn_input) # Example converting an ISBN10 to ISBN13: isbn10 <- "316148410X" valid_isbn <- CheckIsbn(isbn10) ## End(Not run)
## Not run: # Example with a compound string where the first part is the ISBN: isbn_input <- "316148410X, some extra text" valid_isbn <- CheckIsbn(isbn_input) # Example converting an ISBN10 to ISBN13: isbn10 <- "316148410X" valid_isbn <- CheckIsbn(isbn10) ## End(Not run)
Use search parameters for the Cristin API and return the results
as a tibble. See CristinWrangler
Cristin( id = NULL, doi = NULL, title = NULL, contributor = NULL, issn = NULL, unit = NULL, institution = NULL, user = NULL, category = NULL, published_since = NULL, published_before = NULL, created_since = NULL, created_before = NULL, modified_since = NULL, modified_before = NULL, year_reported = NULL, project_code = NULL, funding_source = NULL, funding = NULL, lang = NULL, page = 1, per_page = 1000, max.results = NULL, no.results = FALSE, sort = NULL, filter = NULL, fields = "all", open.query = NULL, all.results = TRUE, force = FALSE, remove.duplicates = TRUE, base.url = "https://api.cristin.no/v2/results", custom.url = NULL, use.identifiers = TRUE, use.multisession = FALSE, min.multisession = 25, n.workers = NULL, n.chunks = NULL, handler = NULL, restore.defaults = TRUE, zotero = NULL, zotero.import = TRUE, zotero.check = TRUE, nvi = FALSE, remove.na = TRUE, replace.na = "book", force.type = NULL, silent = FALSE, log = list() )
Cristin( id = NULL, doi = NULL, title = NULL, contributor = NULL, issn = NULL, unit = NULL, institution = NULL, user = NULL, category = NULL, published_since = NULL, published_before = NULL, created_since = NULL, created_before = NULL, modified_since = NULL, modified_before = NULL, year_reported = NULL, project_code = NULL, funding_source = NULL, funding = NULL, lang = NULL, page = 1, per_page = 1000, max.results = NULL, no.results = FALSE, sort = NULL, filter = NULL, fields = "all", open.query = NULL, all.results = TRUE, force = FALSE, remove.duplicates = TRUE, base.url = "https://api.cristin.no/v2/results", custom.url = NULL, use.identifiers = TRUE, use.multisession = FALSE, min.multisession = 25, n.workers = NULL, n.chunks = NULL, handler = NULL, restore.defaults = TRUE, zotero = NULL, zotero.import = TRUE, zotero.check = TRUE, nvi = FALSE, remove.na = TRUE, replace.na = "book", force.type = NULL, silent = FALSE, log = list() )
id |
The Cristin id of the result, Default: NULL |
doi |
DOI name (e.g. doi=10.1000/123456), Default: NULL |
title |
The title of the result, Default: NULL |
contributor |
Author's name or Cristin person id, Default: NULL |
issn |
The issn of the result, Default: NULL |
unit |
Id (e.g. unit=185.53.18.10), Default: NULL |
institution |
Id (one number, e.g. institution=185), name or acronym of the institution the contributors belong to, Default: NULL |
user |
A person's username in Cristin together with the institution id separated by colon (e.g., 'askeladd:185'), Default: NULL |
category |
Categories. See category codes, Default: NULL |
published_since |
Results published since and inclusive the given year, (yyyy), Default: NULL |
published_before |
Results published before and inclusive the given year, (yyyy), Default: NULL |
created_since |
Results created since and inclusive the given date, (yyyy-mm-dd), Default: NULL |
created_before |
Results created before and inclusive the given date, (yyyy-mm-dd), Default: NULL |
modified_since |
Results modified since and inclusive the given date, (yyyy-mm-dd), Default: NULL |
modified_before |
Results modified before and inclusive the given date, (yyyy-mm-dd), Default: NULL |
year_reported |
The year a result was reported, Default: NULL |
project_code |
Project code is the internal reference number used by funding source, Default: NULL |
funding_source |
Funding source code e.g: NFR, Default: NULL |
funding |
Funding source code e.g: NFR, and project_code together separated by colon (e.g., NFR:1234), Default: NULL |
lang |
Two letter language code, Default: NULL |
page |
Page number. See pagination, Default: 1 |
per_page |
Number of items per page (1000 is max). See pagination, Default: 1000 |
max.results |
Do you need a limit?, Default: NULL |
no.results |
Do you need only the number of results?, Default: FALSE |
sort |
Sorts on 'category' and/or 'year_published'. See search and sort. Default sort order is on 'cristin_result_id' in ascending order, Default: NULL |
filter |
Vector of cateogries to include in results. See category code, Default: NULL |
fields |
'fields = all' gives a list of result objects with all available fields. If this parameter is omitted, a list of result summaries with fewer fields will be returned, Default: all |
open.query |
Define your own query terms, Default: NULL |
all.results |
Find all results in query, Default: TRUE |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
remove.duplicates |
Remove duplicates if TRUE, Default: TRUE |
base.url |
The base url for the Cristin API, Default: https://api.cristin.no/v2/results |
custom.url |
Define your own Cristin API url, Default: NULL |
use.identifiers |
Use if ISBN/DOI identifiers if enabled, Default: TRUE |
use.multisession |
Logical. If |
min.multisession |
Minimum number of results for using multisession. Default: 25 |
n.workers |
Optional integer for the number of workers to be used in
multisession mode. If |
n.chunks |
Optional integer for the number of chunks to process.
If |
handler |
The progress handler to be used by the |
restore.defaults |
Logical. If |
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items), Default: NULL |
zotero.import |
Use |
zotero.check |
Check for Cristin references already stored in Zotero, Default: TRUE |
nvi |
Filter out non-NVI publications Default: FALSE |
remove.na |
Cristin contains many, more or less, obscure categories, and not all are (yet) supported. By default these are removed, however, if this option is set to FALSE unsupported categories are treated according to replace.na, Default: TRUE |
replace.na |
May the odds be in your favor and replace unsupported categories with a predefined itemType if remove.na is set to false, Default: 'book' |
force.type |
Force all items to a predefined itemType, Default: NULL |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
log |
A list for storing log elements, Default: list() |
Please see #' https://oeysan.github.io/c2z/
A list with (exported) items from Cristin
http_error
, GET
,
RETRY
tail
, head
slice
# Simple `Cristin` search by id example <- Cristin(id = "840998") # Print index using `ZoteroIndex` if (any(nrow(example$results))) { ZoteroIndex(example$results) |> dplyr::select(name) |> print(width = 80) }
# Simple `Cristin` search by id example <- Cristin(id = "840998") # Print index using `ZoteroIndex` if (any(nrow(example$results))) { ZoteroIndex(example$results) |> dplyr::select(name) |> print(width = 80) }
Used to filter Cristin categories that are not supported
CristinSupported( data = NULL, zotero.check = TRUE, items = NULL, remove.na = TRUE, replace.na = "book", force.type = NULL, remove.duplicates = TRUE, silent = FALSE, log = list() )
CristinSupported( data = NULL, zotero.check = TRUE, items = NULL, remove.na = TRUE, replace.na = "book", force.type = NULL, remove.duplicates = TRUE, silent = FALSE, log = list() )
data |
Zotero-type matrix, Default: NULL |
zotero.check |
Should the function look for duplicates?, Default: TRUE |
items |
Items in library to check for |
remove.na |
Cristin contains many, more or less, obscure categories, and not all are (yet) supported. By default these are removed, however, if this option is set to FALSE unsupported categories are treated according to replace.na, Default: TRUE |
replace.na |
May the odds be in your favor and replace unsupported categories with a predefined itemType if remove.na is set to false, Default: 'book' |
force.type |
Force all items to a predefined itemType, Default: NULL |
remove.duplicates |
Remove duplicates if TRUE, Default: TRUE |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
Zotero supported items with unsupported categories as NA
# Supported Cristin items print(CristinSupported(), n = 5)
# Supported Cristin items print(CristinSupported(), n = 5)
Converts Cristin metadata into a Zotero-style tibble.
CristinWrangler(data, meta = list(), use.identifiers = TRUE)
CristinWrangler(data, meta = list(), use.identifiers = TRUE)
data |
Tibble containing metadata from Cristin |
meta |
A list for storing data elements, Default: list() |
use.identifiers |
Use if ISBN/DOI identifiers if enabled, Default: TRUE |
Please see https://oeysan.github.io/c2z/
A Zotero-type tibble.
Query CrossRef by DOI and fetch metadata
DoiCrossref(data, meta = list(), use.json = TRUE, silent = TRUE, log = list())
DoiCrossref(data, meta = list(), use.json = TRUE, silent = TRUE, log = list())
data |
XML data from CrossRef containing metadata |
meta |
A list collecting all metadata used to create , Default: list() |
use.json |
Use either json (TRUE) or XML (FALSE), Default: TRUE |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
# `DoiCrossref` is called from `ZoteroDoi` (if item found) example <- ZoteroDoi("10.1126/sciadv.abd1705") # Print index using `ZoteroIndex` if (!is.null(example$data)) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) # Display catalog example$data$libraryCatalog }
# `DoiCrossref` is called from `ZoteroDoi` (if item found) example <- ZoteroDoi("10.1126/sciadv.abd1705") # Print index using `ZoteroIndex` if (!is.null(example$data)) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) # Display catalog example$data$libraryCatalog }
Query DataCite by DOI and fetch metadata
DoiDatacite(data, meta = list(), silent = TRUE, log = list())
DoiDatacite(data, meta = list(), silent = TRUE, log = list())
data |
XML data from DataCite containing metadata |
meta |
A list collecting all metadata used to create , Default: list() |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
# `DoiDatacite` is called from `ZoteroDoi` (if item found) example <- ZoteroDoi("10.17605/OSF.IO/7HZ4P") # Use `ZoteroIndex` to print # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) # Display catalog example$data$libraryCatalog }
# `DoiDatacite` is called from `ZoteroDoi` (if item found) example <- ZoteroDoi("10.17605/OSF.IO/7HZ4P") # Use `ZoteroIndex` to print # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) # Display catalog example$data$libraryCatalog }
This function processes a tibble (or data frame) in parallel using the future
package
along with progressr
for progress reporting. The data is split into chunks via a helper function
SplitData
. Depending on the by.rows
flag, each chunk is processed either row-by-row
(using lapply
) or as an entire chunk. In either case, the processed results are bound into a single tibble.
ProcessData( data, func, by.rows = TRUE, min.multisession = 1, n.workers = NULL, n.chunks = NULL, limit = 100, use.multisession = TRUE, start.message = NULL, end.message = NULL, restore.defaults = TRUE, handler = NULL, silent = FALSE, log = list(), ... )
ProcessData( data, func, by.rows = TRUE, min.multisession = 1, n.workers = NULL, n.chunks = NULL, limit = 100, use.multisession = TRUE, start.message = NULL, end.message = NULL, restore.defaults = TRUE, handler = NULL, silent = FALSE, log = list(), ... )
data |
Data to be processed. |
func |
A function that processes either a single row (if |
by.rows |
Logical. If |
min.multisession |
Integer. The minimum number of rows in |
n.workers |
Integer. The number of workers to use for parallel processing.
Defaults to |
n.chunks |
Integer. The number of chunks into which the data is split.
If |
limit |
Integer. If |
use.multisession |
Logical. If |
start.message |
Optional character string. A custom message to log at the start of processing. |
end.message |
Optional character string. A custom message to log at the end of processing. |
restore.defaults |
Logical. If |
handler |
Character string. The progress handler to be used by the |
silent |
Logical. If |
log |
List. An initial log (default is an empty list) to which log messages are appended. |
... |
Additional arguments passed to the processing function |
The function first checks if the data has enough rows to warrant parallel processing.
It then determines the number of workers and chunks and splits the data using the helper function
SplitData
. The processing is executed with future.apply::future_lapply
in parallel. If by.rows
is TRUE
,
each row within a chunk is processed individually and then bound together using dplyr::bind_rows
;
if by.rows
is FALSE
, the entire chunk is processed at once. Finally, all chunk results are combined
into a single tibble.
A list with two components:
A tibble resulting from binding all processed rows from each chunk.
A list of log messages generated during processing.
## Not run: example.result <- ProcessData( data = tibble::tibble( key = LETTERS[1:3], value = seq(3) ), func = \(data) { data$value <- data$value * 10 data }, by.rows = FALSE, min.multisession = 10, n.workers = 4, n.chunks = 4, limit = 100, use.multisession = TRUE, start.message = "Starting example data processing", end.message = "Finished example data processing", handler = "txtprogressbar", silent = FALSE ) # The result is a single tibble. processed.tibble <- example.result$results process.log <- example.result$log if (any(nrow(processed.tibble))) print(processed.tibble) ## End(Not run)
## Not run: example.result <- ProcessData( data = tibble::tibble( key = LETTERS[1:3], value = seq(3) ), func = \(data) { data$value <- data$value * 10 data }, by.rows = FALSE, min.multisession = 10, n.workers = 4, n.chunks = 4, limit = 100, use.multisession = TRUE, start.message = "Starting example data processing", end.message = "Finished example data processing", handler = "txtprogressbar", silent = FALSE ) # The result is a single tibble. processed.tibble <- example.result$results process.log <- example.result$log if (any(nrow(processed.tibble))) print(processed.tibble) ## End(Not run)
This function executes a provided expression with progress reporting and optional
parallel processing using the future
and progressr
packages. It logs the
start and end times of the process along with a runtime message and supports custom logging,
progress handlers, and execution plans.
Processing( func = substitute(NULL), n = NULL, start.message = NULL, end.message = NULL, use.multisession = TRUE, n.workers = NULL, n.chunks = NULL, handler = NULL, restore.defaults = TRUE, silent = FALSE, log = list() )
Processing( func = substitute(NULL), n = NULL, start.message = NULL, end.message = NULL, use.multisession = TRUE, n.workers = NULL, n.chunks = NULL, handler = NULL, restore.defaults = TRUE, silent = FALSE, log = list() )
func |
An expression (or a quoted function call) to be evaluated. The default is
|
n |
Optional integer indicating the number of items to be processed, used solely for logging purposes. |
start.message |
Optional character string specifying a custom start message. If |
end.message |
Optional character string specifying a custom end message. If |
use.multisession |
Logical. If |
n.workers |
Optional integer for the number of workers to be used in
multisession mode. If |
n.chunks |
Optional integer for the number of chunks to process.
If |
handler |
The progress handler to be used by the |
restore.defaults |
Logical. If |
silent |
Logical. If |
log |
A list to collect log messages. Default is an empty list. |
The function begins by determining whether to use multisession (parallel) or sequential processing.
It then logs the start time using a helper function, LogCat
, and sets up the future
plan
accordingly. If restore.defaults
is TRUE
, the original plan is restored after execution.
A progress handler is configured via the progressr
package. The provided expression is evaluated
with progress reporting enabled. Upon completion, the function computes the elapsed time (with millisecond
precision) and logs an end message. Finally, it returns a list containing the result of the evaluated expression
and the log of messages.
A list with the following components:
The output resulting from the evaluation of func
.
A list of log messages including start and end timestamps along with associated messages.
## Not run: # Example: Process data with a simple sleep expression using multisession processing result <- Processing( func = quote({ Sys.sleep(2) # simulate a time-consuming task "Task Completed" }), n = 100, use.multisession = TRUE ) print(result$result) print(result$log) ## End(Not run)
## Not run: # Example: Process data with a simple sleep expression using multisession processing result <- Processing( func = quote({ Sys.sleep(2) # simulate a time-consuming task "Task Completed" }), n = 100, use.multisession = TRUE ) print(result$result) print(result$log) ## End(Not run)
Combines two data frames by updating rows in x
with values from y
based on a common key,
and inserting new rows from y
that are not present in x
. The function first harmonizes the
column structures of both data frames by adding missing columns and coercing types as necessary.
UpdateInsert(x, y, key = "key", check.missing = FALSE)
UpdateInsert(x, y, key = "key", check.missing = FALSE)
x |
A data frame to be updated. |
y |
A data frame containing new values to update |
key |
A character string specifying the unique key column used for matching rows. Defaults to |
check.missing |
Logical; if |
The function works in several steps:
It computes the union of all column names from x
and y
and adds any missing columns
to both data frames using the internal helper function AddColumns
. Missing columns are filled
with an appropriate NA
value based on their type.
Both x
and y
are reordered to have the same column order.
For each common column (excluding the key), if x
's column is entirely NA
or if the
data types differ, coercion is performed to ensure compatibility between x
and y
.
When check.missing
is TRUE
, the function iterates over each common key and updates each
cell in x
only if the corresponding cell in y
is not missing. Otherwise, it uses
dplyr::rows_upsert
to perform a standard upsert.
New rows present in y
but not in x
are appended.
A data frame resulting from updating x
with values from y
.
## Not run: # Example data frames: df1 <- data.frame( key = 1:3, a = c(NA, 2, NA), b = c("x", NA, "z"), stringsAsFactors = FALSE ) df2 <- data.frame( key = c(2, 3, 4), a = c(5, 6, 7), b = c("y", "w", "v"), stringsAsFactors = FALSE ) # Standard upsert (check.missing = FALSE): result <- UpdateInsert(df1, df2, key = "key", check.missing = FALSE) # Cell-by-cell update (check.missing = TRUE): result <- UpdateInsert(df1, df2, key = "key", check.missing = TRUE) ## End(Not run)
## Not run: # Example data frames: df1 <- data.frame( key = 1:3, a = c(NA, 2, NA), b = c("x", NA, "z"), stringsAsFactors = FALSE ) df2 <- data.frame( key = c(2, 3, 4), a = c(5, 6, 7), b = c("y", "w", "v"), stringsAsFactors = FALSE ) # Standard upsert (check.missing = FALSE): result <- UpdateInsert(df1, df2, key = "key", check.missing = FALSE) # Cell-by-cell update (check.missing = TRUE): result <- UpdateInsert(df1, df2, key = "key", check.missing = TRUE) ## End(Not run)
Wrapper to connect with the Zotero API and the main functions of *c2z*
Zotero( collection.names = NULL, collection.key = NULL, collection.path = NULL, item.key = NULL, library = FALSE, case.insensitive = TRUE, ancestor = FALSE, recursive = FALSE, create = FALSE, limit = 100, start = 0, search.collections = TRUE, get.collections = TRUE, get.items = TRUE, item.type = NULL, all.results = TRUE, max.results = NULL, collections = NULL, items = NULL, attachments = NULL, metadata = NULL, doi = NULL, isbn = NULL, export = FALSE, csl.type = NULL, csl.name = "style", format = "biblatex", save.data = FALSE, save.path = NULL, bib.name = "references", library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", copy = FALSE, copy.collections = TRUE, copy.items = TRUE, copy.extras = TRUE, remove.missing = TRUE, change.library = FALSE, copy.user = TRUE, copy.id = NULL, copy.api = NULL, post = FALSE, post.collections = TRUE, post.items = TRUE, post.attachments = TRUE, post.limit = 50, post.token = FALSE, delete = FALSE, delete.collections = FALSE, delete.items = FALSE, delete.limit = 50, ragnarok = FALSE, user = TRUE, index = FALSE, id = NULL, token = NULL, token.api = NULL, api = NULL, force = FALSE, base.url = "https://api.zotero.org", silent = FALSE, zotero = NULL, log = list() )
Zotero( collection.names = NULL, collection.key = NULL, collection.path = NULL, item.key = NULL, library = FALSE, case.insensitive = TRUE, ancestor = FALSE, recursive = FALSE, create = FALSE, limit = 100, start = 0, search.collections = TRUE, get.collections = TRUE, get.items = TRUE, item.type = NULL, all.results = TRUE, max.results = NULL, collections = NULL, items = NULL, attachments = NULL, metadata = NULL, doi = NULL, isbn = NULL, export = FALSE, csl.type = NULL, csl.name = "style", format = "biblatex", save.data = FALSE, save.path = NULL, bib.name = "references", library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", copy = FALSE, copy.collections = TRUE, copy.items = TRUE, copy.extras = TRUE, remove.missing = TRUE, change.library = FALSE, copy.user = TRUE, copy.id = NULL, copy.api = NULL, post = FALSE, post.collections = TRUE, post.items = TRUE, post.attachments = TRUE, post.limit = 50, post.token = FALSE, delete = FALSE, delete.collections = FALSE, delete.items = FALSE, delete.limit = 50, ragnarok = FALSE, user = TRUE, index = FALSE, id = NULL, token = NULL, token.api = NULL, api = NULL, force = FALSE, base.url = "https://api.zotero.org", silent = FALSE, zotero = NULL, log = list() )
collection.names |
Vector of collection names to create or search for, Default: NULL |
collection.key |
A specified collection key, Default: NULL |
collection.path |
Vector of nested collection keys, Default: NULL |
item.key |
A specified item key, Default: NULL |
library |
Use 'ZoteroLibrary' to fetch collections and items, Default: FALSE |
case.insensitive |
Disregard letter casing when searching for collections, Default: TRUE |
ancestor |
Trace the lineage of a collection (i.e., find the top-level collection), Default: FALSE |
recursive |
Find all nested collections, Default: FALSE |
create |
Create missing collections, Default: FALSE |
limit |
Number of results per query (max 100), Default: 100 |
start |
Starting position of query (0 = first result), Default: 0 |
search.collections |
Search all collections if collection.key fails, Default: TRUE |
get.collections |
Fetch collections, Default: TRUE |
get.items |
Fetch items, Default: TRUE |
item.type |
Items to search for (NULL = everything), Default: NULL |
all.results |
Find all results in query, Default: TRUE |
max.results |
Do you need a limit?, Default: NULL |
collections |
Predefined collections (as tibble), Default: NULL |
items |
Predefined metadata (as tibble), Default: NULL |
attachments |
Predefined attachments (as tibble), Default: NULL |
metadata |
Predefined metadata in Zotero-format, Default: NULL |
doi |
Use |
isbn |
Use |
export |
Use 'ZoteroExport' to export items, Default: FALSE |
csl.type |
Specify a CSL type to Official repository for Citation Style Language (CSL), Default: NULL |
csl.name |
Name of saved CSL file, Default: 'style' |
format |
Export format of Zotero items, Default: 'biblatex' |
save.data |
Save data (e.g., bibliography) to disk, Default: FALSE |
save.path |
Location to store data on disk, Default: NULL |
bib.name |
Name of exported bibliography, Default: 'references' |
library.type |
Commma-separated data from Zotero (i.e., data, bib, citation), Default: NULL |
linkwrap |
Set URL (e.g., DOI) as HTML link (1 = yes), Default: 1 |
style |
Citation style to use for appended bibliography and/or citations, Default: apa |
locale |
Desired language format of bibliography, Default: 'en-US' |
copy |
Use 'ZoteroCopy' to delete collections and/or items, Default: FALSE |
copy.collections |
Try to copy specified collections, Default: TRUE |
copy.items |
Try to copy specified items?, Default: TRUE |
copy.extras |
Try to copy specified extras (i.e., attachments and notes)?, Default: TRUE |
remove.missing |
Deleted missing extras, Default: TRUE |
change.library |
Stage changing of library (e.g., from a group to a personal library), Default: FALSE |
copy.user |
New user type (The functions will use 'group' as prefix if FALSE), Default: TRUE |
copy.id |
New id, Default: NULL |
copy.api |
New API key. Set API to 'NA' if key is not needed, Default: NULL |
post |
Use 'ZoteroPost' to post collections and/or items, Default: FALSE |
post.collections |
Try to copy specified collections, Default: TRUE |
post.items |
Try to copy specified items?, Default: TRUE |
post.attachments |
Try to copy specified extras (i.e., attachments and notes)?, Default: TRUE |
post.limit |
Number of collections/items to post per request (max 50), Default: 50 |
post.token |
Use Zotero-Write-Token (TRUE) or If-Unmodified-Since-Version (FALSE), Default: FALSE |
delete |
Use 'ZoteroDelete' to delete collections and/or items, Default: FALSE |
delete.collections |
Try to delete specified collections, Default: TRUE |
delete.items |
Try to delete specified items?, Default: TRUE |
delete.limit |
Number of collections/items to delete per request (max 50), Default: 50 |
ragnarok |
Delete EVERYTHING in the specified library, Default: FALSE |
user |
User type (The functions will use 'group' as prefix if FALSE), Default: TRUE |
index |
Create an index of items, Default: FALSE |
id |
User or group ID, Default: NULL |
token |
Name of user or group token as defined in '.Renviron', Default: NULL |
token.api |
Name of API token as defined in '.Renviron', Default: NULL |
api |
API key to connect with the Zotero library. Set API to 'NA' if key is not needed. See Zotero API, Default: NULL |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
base.url |
Base url of the Zotero API, Default: 'https://api.zotero.org' |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items), Default: NULL |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., id, API key, collections, and items)
# Create the default Zotero list example <- Zotero(id = "9913421", api = "RqlAmlH5l1KPghfCseAq1sQ1") # Print the interesting pars of an otherwise empty list print(tail(example,5))
# Create the default Zotero list example <- Zotero(id = "9913421", api = "RqlAmlH5l1KPghfCseAq1sQ1") # Print the interesting pars of an otherwise empty list print(tail(example,5))
Use identifiers or predefined data to add to the Zotero list
ZoteroAdd(zotero, metadata = NULL, doi = NULL, isbn = NULL, silent = FALSE)
ZoteroAdd(zotero, metadata = NULL, doi = NULL, isbn = NULL, silent = FALSE)
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
metadata |
Predefined metadata in Zoter-format, Default: NULL |
doi |
Use |
isbn |
Use |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
Will add data to the Zotero list
# Add items from `ZoteroIsbn` to the default Zotero list example <- ZoteroAdd( Zotero( id = "9913421", api = "RqlAmlH5l1KPghfCseAq1sQ1" ), isbn = "978-1529797138" ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
# Add items from `ZoteroIsbn` to the default Zotero list example <- ZoteroAdd( Zotero( id = "9913421", api = "RqlAmlH5l1KPghfCseAq1sQ1" ), isbn = "978-1529797138" ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
Removes references from the input dataset that are duplicates already added to Zotero, preserving only those references that have been modified since their addition.
ZoteroCheck( data, id, id.type, created, last.modified, items, remove.duplicates = TRUE, silent = FALSE, log = list() )
ZoteroCheck( data, id, id.type, created, last.modified, items, remove.duplicates = TRUE, silent = FALSE, log = list() )
data |
A tibble containing metadata (e.g., from Cristin) |
id |
A string specifying the column name in |
id.type |
A string specifying the type of metadata as stored in the Zotero extra field (e.g., "Cristin") |
created |
A string specifying the column name in |
last.modified |
A string specifying the column name in |
items |
A data frame or tibble representing items in the Zotero library to check against |
remove.duplicates |
Logical. If |
silent |
Logical. If |
log |
A list for storing log messages. Default is an empty list. |
For more details, see c2z documentation.
A list with two elements: data
, a tibble containing
non-duplicated items, and log
, the updated log list.
arrange
,
coalesce
,
bind_rows
,
filter
## Not run: # Simple Cristin search by id cristin.data <- Cristin( id = "840998", zotero.import = FALSE ) # Checking Zotero library for duplicates result <- ZoteroCheck( data = cristin.data$result, id = "cristin_result_id", id.type = "Cristin", created = "created", last.modified = "last_modified", items = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE, silent = TRUE )$items ) ## End(Not run)
## Not run: # Simple Cristin search by id cristin.data <- Cristin( id = "840998", zotero.import = FALSE ) # Checking Zotero library for duplicates result <- ZoteroCheck( data = cristin.data$result, id = "cristin_result_id", id.type = "Cristin", created = "created", last.modified = "last_modified", items = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE, silent = TRUE )$items ) ## End(Not run)
Replace key identifiers with new ones while keeping existing structure and relationship between collections and items
ZoteroCopy( zotero, copy.collections = TRUE, copy.items = TRUE, copy.extras = TRUE, remove.missing = TRUE, change.library = FALSE, copy.user = TRUE, copy.id = NULL, copy.api = NULL, silent = FALSE )
ZoteroCopy( zotero, copy.collections = TRUE, copy.items = TRUE, copy.extras = TRUE, remove.missing = TRUE, change.library = FALSE, copy.user = TRUE, copy.id = NULL, copy.api = NULL, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
copy.collections |
Try to copy specified collections, Default: TRUE |
copy.items |
Try to copy specified items?, Default: TRUE |
copy.extras |
Try to copy specified extras (i.e., attachments and notes)?, Default: TRUE |
remove.missing |
Deleted missing extras, Default: TRUE |
change.library |
Stage changing of library (e.g., from a group to a personal library), Default: FALSE |
copy.user |
New user type (The functions will use 'group' as prefix if FALSE), Default: TRUE |
copy.id |
New id, Default: NULL |
copy.api |
New API key, Default: NULL |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., copied collections and items)
GET
mutate
, case_when
,
filter
, select
,
across
, arrange
pmap
all_of
# Fetching collections and items from default group zotero = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE ) # Display collections if (any(nrow(zotero$collections))) { zotero$collections |> dplyr::select(key, version, parentCollection) |> print(width = 80) } # Display items if (any(nrow(zotero$items))) { zotero$items |> dplyr::select(key, version) |> print(width = 80) } # Copy items example <- ZoteroCopy( zotero, ) # Display collections if (any(nrow(example$collections))) { example$collections |> dplyr::select(key, version, parentCollection) |> print(width = 80) } # Display items if (any(nrow(example$items))) { example$items |> dplyr::select(key, version) |> print(width = 80) }
# Fetching collections and items from default group zotero = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE ) # Display collections if (any(nrow(zotero$collections))) { zotero$collections |> dplyr::select(key, version, parentCollection) |> print(width = 80) } # Display items if (any(nrow(zotero$items))) { zotero$items |> dplyr::select(key, version) |> print(width = 80) } # Copy items example <- ZoteroCopy( zotero, ) # Display collections if (any(nrow(example$collections))) { example$collections |> dplyr::select(key, version, parentCollection) |> print(width = 80) } # Display items if (any(nrow(example$items))) { example$items |> dplyr::select(key, version) |> print(width = 80) }
Query CRAN by name and fetch metadata
ZoteroCran(id, meta = list(), silent = TRUE, log = list())
ZoteroCran(id, meta = list(), silent = TRUE, log = list())
id |
name of R package |
meta |
A list collecting all metadata used to create , Default: list() |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
# Search cran for package `dplyr` example <- ZoteroCran(c("dplyr", "jsonlite", "httr")) # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
# Search cran for package `dplyr` example <- ZoteroCran(c("dplyr", "jsonlite", "httr")) # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
Cleaning the Zotero library
ZoteroDelete( zotero, delete.collections = FALSE, delete.items = FALSE, delete.limit = 50, force = FALSE, ragnarok = FALSE, silent = FALSE )
ZoteroDelete( zotero, delete.collections = FALSE, delete.items = FALSE, delete.limit = 50, force = FALSE, ragnarok = FALSE, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
delete.collections |
Try to delete specified collections, Default: TRUE |
delete.items |
Try to delete specified items?, Default: TRUE |
delete.limit |
Number of collections/items to delete per request (max 50), Default: 50 |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
ragnarok |
Delete EVERYTHING in the specified library, Default: FALSE |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., deleted collections and items)
# Delete everything in a group example <- ZoteroDelete( Zotero( user = FALSE, id = "4988497", api = "RqlAmlH5l1KPghfCseAq1sQ1" ), ragnarok = TRUE, force = TRUE )
# Delete everything in a group example <- ZoteroDelete( Zotero( user = FALSE, id = "4988497", api = "RqlAmlH5l1KPghfCseAq1sQ1" ), ragnarok = TRUE, force = TRUE )
Connects with doi.org to create metadata
ZoteroDoi( doi, meta = list(), use.semantic = TRUE, check.retraction = TRUE, use.json = TRUE, silent = TRUE, log = list() )
ZoteroDoi( doi, meta = list(), use.semantic = TRUE, check.retraction = TRUE, use.json = TRUE, silent = TRUE, log = list() )
doi |
A digital object identifier |
meta |
A list collecting all metadata used to create , Default: list() |
use.semantic |
Get metadata (abstract) from Semantic Scholar, Default: FALSE |
check.retraction |
Check if marked as retracted, Default: TRUE |
use.json |
Use either json (TRUE) or XML (FALSE), Default: TRUE |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
http_error
, GET
,
RETRY
rename
, html_attr
,
html_text
, reexports
,
html_children
, html_name
bind
, arrange
# Simple use of `ZoteroDoi` example <- ZoteroDoi("10.1126/sciadv.abd1705") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
# Simple use of `ZoteroDoi` example <- ZoteroDoi("10.1126/sciadv.abd1705") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
This function iterates over a data frame (or tibble) of Zotero records and attempts to enhance
each record by retrieving additional metadata from external sources. It uses DOI or ISBN information,
via the c2z
package, to fetch external metadata and then merges these updates into the original
Zotero record. Special handling is provided for records representing book sections.
ZoteroEnhancer( zotero.data, external.data = NULL, use.doi = TRUE, use.semantic = TRUE, use.isbn = TRUE )
ZoteroEnhancer( zotero.data, external.data = NULL, use.doi = TRUE, use.semantic = TRUE, use.isbn = TRUE )
zotero.data |
A data frame (or tibble) containing Zotero records. Each row represents a record
that may include fields such as |
external.data |
Optional. A data frame or list containing pre-fetched external metadata.
If provided and non-empty, the function will use this external metadata to update the Zotero records
instead of querying the external APIs. Defaults to |
use.doi |
Logical; if |
use.semantic |
Logical; if |
use.isbn |
Logical; if |
For each record in zotero.data
, the function performs the following steps:
If external.data
is provided and non-empty, that data is used to update the record.
Otherwise, the function skips processing the record if an abstract already exists.
It then attempts to extract a DOI from the DOI
field, or if missing, from the url
field.
The ISBN
field is processed by removing spaces and extracting the first value (in case of comma separation).
If a valid DOI is found and use.doi
is TRUE
, external metadata is retrieved using c2z::ZoteroDoi()
.
Otherwise, if an ISBN is available and use.isbn
is TRUE
, metadata is retrieved using c2z::ZoteroIsbn()
.
Once external metadata is successfully retrieved, an internal helper function UpdateTibble
is called.
This helper function merges the external metadata into the original record. For book sections, additional
adjustments are made to handle creator information, pages, and edition fields.
Finally, the enhanced record is merged back into the original data frame using UpdateInsert()
.
A data frame containing the enhanced Zotero records with external metadata merged into the original records.
## Not run: # Enhance Zotero records using DOI/ISBN lookup: example <- Cristin("762394", silent = TRUE)$results print(example$libraryCatalog) example$DOI <- "https://doi.org/10.22358/jafs/74164/2007" enhanced.data <- ZoteroEnhancer(example) print(enhanced.data$libraryCatalog) ## End(Not run)
## Not run: # Enhance Zotero records using DOI/ISBN lookup: example <- Cristin("762394", silent = TRUE)$results print(example$libraryCatalog) example$DOI <- "https://doi.org/10.22358/jafs/74164/2007" enhanced.data <- ZoteroEnhancer(example) print(enhanced.data$libraryCatalog) ## End(Not run)
Export Zotero items to a specified format (e.g., BibLaTeX) using a CSL format (e.g., APA7)
ZoteroExport( zotero, csl.type = NULL, csl.name = "style", locale = "en-US", format = "biblatex", bib.name = "references", save.data = FALSE, save.path = NULL, silent = FALSE )
ZoteroExport( zotero, csl.type = NULL, csl.name = "style", locale = "en-US", format = "biblatex", bib.name = "references", save.data = FALSE, save.path = NULL, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
csl.type |
Specify a CSL type to Official repository for Citation Style Language (CSL), Default: NULL |
csl.name |
Name of saved CSL file, Default: 'style' |
locale |
Desired language format of bibliography, Default: 'en-US' |
format |
Export format of Zotero items, Default: 'biblatex' |
bib.name |
Name of exported bibliography, Default: 'references' |
save.data |
Save data (e.g., bibliography) to disk, Default: FALSE |
save.path |
Location to store data on disk, Default: NULL |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., exported items, bibliography and citations)
# Define Zotero list according to default group zotero = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", item.type = "-attachment || note", max.result = 1, library = TRUE ) # Export 1 items from the default group example <- ZoteroExport( zotero ) # Display exported cat(example$export, fill = 80)
# Define Zotero list according to default group zotero = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", item.type = "-attachment || note", max.result = 1, library = TRUE ) # Export 1 items from the default group example <- ZoteroExport( zotero ) # Display exported cat(example$export, fill = 80)
Make a Zotero friendly format of input data, will add a zotero key.
ZoteroFormat( data = NULL, format = NULL, prefix = NULL, check.structure = FALSE, fix.columns = TRUE, silent = FALSE )
ZoteroFormat( data = NULL, format = NULL, prefix = NULL, check.structure = FALSE, fix.columns = TRUE, silent = FALSE )
data |
A list of metadata or something else, Default: NULL |
format |
The format of the input data (e.g., 'JSON', 'versions', 'keys). , Default: NULL |
prefix |
Add a prefix to the metadata (e.g., user/userID), Default: NULL |
check.structure |
Check that the structure of a data frame is correct according to the Zotero type, Default: FALSE |
fix.columns |
Remove columns not part of the Zotero type, Default: TRUE |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
A zotero friendly tibble if requested otherwise format the data according to format.
tibble
, as_tibble
toJSON, fromJSON
mutate_all
, na_if
,
mutate
, across
,
reexports
, select
map
ZoteroFormat( list(title = "This is a test", itemType = "document") )
ZoteroFormat( list(title = "This is a test", itemType = "document") )
Get
ZoteroGet( zotero, use.collection = TRUE, use.item = FALSE, append.collections = FALSE, append.items = FALSE, append.top = FALSE, append.file = FALSE, custom.url = NULL, open.query = NULL, limit = 100, start = 0, format = "json", item.keys = NULL, collection.keys = NULL, item.type = NULL, library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", all.results = TRUE, max.results = NULL, result.type = NULL, force = FALSE, silent = FALSE )
ZoteroGet( zotero, use.collection = TRUE, use.item = FALSE, append.collections = FALSE, append.items = FALSE, append.top = FALSE, append.file = FALSE, custom.url = NULL, open.query = NULL, limit = 100, start = 0, format = "json", item.keys = NULL, collection.keys = NULL, item.type = NULL, library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", all.results = TRUE, max.results = NULL, result.type = NULL, force = FALSE, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
use.collection |
Use collection key if present in Zotero list, Default: TRUE |
use.item |
Use item key if present in Zotero list, Default: FALSE |
append.collections |
Append '/collections/' to Zotero API url, Default: FALSE |
append.items |
Append '/items/' to Zotero API url, Default: FALSE |
append.top |
Append '/top/' to Zotero API url, Default: FALSE |
append.file |
Append '/file/' to Zotero API url, Default: FALSE |
custom.url |
Use a custom Zotero API url, Default: NULL |
open.query |
Use your own query, Default: NULL |
limit |
Number of results per query (max 100), Default: 100 |
start |
Starting position of query (0 = first result), Default: 0 |
format |
Format of response from the Zotero API, Default: 'json' |
item.keys |
Specified vector of items keys, Default: NULL |
collection.keys |
Specified vector of collection keys, Default: NULL |
item.type |
Items to search for (NULL = everything), Default: NULL |
library.type |
Commma-separated data from Zotero (i.e., data, bib, citation), Default: NULL |
linkwrap |
Set URL (e.g., DOI) as HTML link (1 = yes), Default: 1 |
style |
Citation style to use for appended bibliography and/or citations, Default: apa |
locale |
Desired language format of bibliography, Default: 'en-US' |
all.results |
Find all results in query, Default: TRUE |
max.results |
Do you need a limit?, Default: NULL |
result.type |
Pointless linguistics to display result type (default = 'result'), Default: NULL |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., collections and items)
# Define Zotero list according to default setings zotero = Zotero( user = FALSE, id = "5250382", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) # Query default group Zotero library for 1 item example <- ZoteroGet( zotero, max.results = 1 ) # Print index using `ZoteroIndex` if (any(nrow(example$results))) { ZoteroIndex(example$results) |> dplyr::select(name) |> print(width = 80) }
# Define Zotero list according to default setings zotero = Zotero( user = FALSE, id = "5250382", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) # Query default group Zotero library for 1 item example <- ZoteroGet( zotero, max.results = 1 ) # Print index using `ZoteroIndex` if (any(nrow(example$results))) { ZoteroIndex(example$results) |> dplyr::select(name) |> print(width = 80) }
Query regjeringen by search word and type and fetch metadata
ZoteroGov(search, type = "NOU", meta = list(), silent = TRUE, log = list())
ZoteroGov(search, type = "NOU", meta = list(), silent = TRUE, log = list())
search |
Search term (e.g., 2018: 2) |
type |
type of query (e.g., white paper, official norwegian reports), Default: "NOU" |
meta |
A list collecting all metadata used to create , Default: list() |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
# Search the default entity, Norwegian official reports in regjeringen.no example <- ZoteroGov("2001:4") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
# Search the default entity, Norwegian official reports in regjeringen.no example <- ZoteroGov("2001:4") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
The function creates a index containing key information about the present Zotero items
ZoteroIndex(data)
ZoteroIndex(data)
data |
Tibble containing Zotero-type metadata (e.g., from Cristin) |
Please see https://oeysan.github.io/c2z/
A tibble
filter
, mutate
,
across
, na_if
,
case_when
, arrange
,
group_by
, context
,
select
everything
pmap
# Access the default group library example = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
# Access the default group library example = Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1", library = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
Query libraries using ISBN (or MMS ID) and fetch metadata
ZoteroIsbn(keys, meta = list(), silent = TRUE, log = list())
ZoteroIsbn(keys, meta = list(), silent = TRUE, log = list())
keys |
Keys to search with (e.g., ISBN or MMS ID) |
meta |
A list collecting all metadata used to create , Default: list() |
silent |
c2z is noisy, tell it to be quiet, Default: TRUE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble)
rename
, html_children
,
html_attr
, html_text
,
reexports
bind
, distinct
,
arrange
tibble
RETRY
setNames
toJSON, fromJSON
# Search libraries for ISBN metadata example <- ZoteroIsbn("978-1529797138") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
# Search libraries for ISBN metadata example <- ZoteroIsbn("978-1529797138") # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
Create an identifier for Zotero items/collections or a write token to library
ZoteroKey(token = FALSE)
ZoteroKey(token = FALSE)
token |
Create a write token, Default: FALSE |
Please see https://oeysan.github.io/c2z/
Will return a 8 character Zotero key or 32 character write token
# Create a Zotero key key <- ZoteroKey() # Create a write token token <- ZoteroKey(TRUE)
# Create a Zotero key key <- ZoteroKey() # Create a write token token <- ZoteroKey(TRUE)
The function uses information stored in the 'zotero' list to access specified collections and items in the Zotero library
ZoteroLibrary( zotero, case.insensitive = TRUE, ancestor = FALSE, recursive = FALSE, create = FALSE, limit = 100, start = 0, search.collections = TRUE, get.collections = TRUE, get.items = TRUE, item.type = NULL, all.results = TRUE, max.results = NULL, library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", force = FALSE, silent = FALSE )
ZoteroLibrary( zotero, case.insensitive = TRUE, ancestor = FALSE, recursive = FALSE, create = FALSE, limit = 100, start = 0, search.collections = TRUE, get.collections = TRUE, get.items = TRUE, item.type = NULL, all.results = TRUE, max.results = NULL, library.type = NULL, linkwrap = 1, style = "apa", locale = "en-US", force = FALSE, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
case.insensitive |
Disregard letter casing when searching for collections, Default: TRUE |
ancestor |
Trace the lineage of a collection (i.e., find the top-level collection), Default: FALSE |
recursive |
Find all nested collections, Default: FALSE |
create |
Create missing collections, Default: FALSE |
limit |
Number of results per query (max 100), Default: 100 |
start |
Starting position of query (0 = first result), Default: 0 |
search.collections |
Search all collections if collection.key fails, Default: TRUE |
get.collections |
Fetch collections, Default: TRUE |
get.items |
Fetch items, Default: TRUE |
item.type |
Items to search for (NULL = everything), Default: NULL |
all.results |
Find all results in query, Default: TRUE |
max.results |
Do you need a limit?, Default: NULL |
library.type |
Commma-separated data from Zotero (i.e., data, bib, citation), Default: NULL |
linkwrap |
Set URL (e.g., DOI) as HTML link (1 = yes), Default: 1 |
style |
Citation style to use for appended bibliography and/or citations, Default: apa |
locale |
Desired language format of bibliography, Default: 'en-US' |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., collections and items)
toJSON, fromJSON
distinct
, arrange
tibble
# Access the default group library example <- ZoteroLibrary( Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
# Access the default group library example <- ZoteroLibrary( Zotero( user = FALSE, id = "4827927", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) ) # Print index using `ZoteroIndex` if (any(nrow(example$items))) { ZoteroIndex(example$items) |> dplyr::select(name) |> print(width = 80) }
Use the CrossRef API to match data (e.g., Cristin metadata with Crossref metadata) or search by title, authors and date
ZoteroMatch( title, authors, date, haystack = NULL, haystack.size = 3, crossref.search = FALSE, autosearch = FALSE, cristin.data = NULL, external.data = NULL, polite = TRUE, silent = FALSE, use.semantic = FALSE, log = list() )
ZoteroMatch( title, authors, date, haystack = NULL, haystack.size = 3, crossref.search = FALSE, autosearch = FALSE, cristin.data = NULL, external.data = NULL, polite = TRUE, silent = FALSE, use.semantic = FALSE, log = list() )
title |
Title of reference |
authors |
creators of the reference |
date |
publication date of the reference |
haystack |
Potential matches for search term (i.e., needle), Default: NULL |
haystack.size |
Number of items in the haystack, Default: 3 |
crossref.search |
Search CrossRef if needle not found in haystack, Default: FALSE |
autosearch |
Match automatically or compare needle with haystack, Default: FALSE |
cristin.data |
Metadata from Cristin, Default: NULL |
external.data |
Metadata from external source (e.g., CrossRef), Default: NULL |
polite |
Will use an email stored in '.Renviron', Default: TRUE |
silent |
Running silent, running deep, Default: FALSE |
use.semantic |
Prefer metadata from Semantic Scholar, Default: FALSE |
log |
A list for storing log elements, Default: list() |
Please see https://oeysan.github.io/c2z/
A Zotero-type matrix (tibble) if match is found otherwise NULL
select
, reexports
,
mutate
, coalesce
,
pull
sym
RETRY
toJSON, fromJSON
adist
, head
map
# Conduct an autosearch in CrossRef using title, authors and date example <- ZoteroMatch( title = "Nonreplicable publications", authors = "Serra-Garcia & Gneezy", date = "2021", autosearch = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
# Conduct an autosearch in CrossRef using title, authors and date example <- ZoteroMatch( title = "Nonreplicable publications", authors = "Serra-Garcia & Gneezy", date = "2021", autosearch = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(example$data))) { ZoteroIndex(example$data) |> dplyr::select(name) |> print(width = 80) }
Create or update collections and items in a specified library
ZoteroPost( zotero, post.collections = TRUE, post.items = TRUE, post.attachments = TRUE, post.limit = 50, post.token = FALSE, force = FALSE, silent = FALSE )
ZoteroPost( zotero, post.collections = TRUE, post.items = TRUE, post.attachments = TRUE, post.limit = 50, post.token = FALSE, force = FALSE, silent = FALSE )
zotero |
A list with information on the specified Zotero library (e.g., id, API key, collections, and items) |
post.collections |
Try to copy specified collections, Default: TRUE |
post.items |
Try to copy specified items?, Default: TRUE |
post.attachments |
Try to copy specified extras (i.e., attachments and notes)?, Default: TRUE |
post.limit |
Number of collections/items to post per request (max 50), Default: 50 |
post.token |
Use Zotero-Write-Token (TRUE) or If-Unmodified-Since-Version (FALSE), Default: FALSE |
force |
Force is seldom wise, but sometimes..., Default: FALSE |
silent |
c2z is noisy, tell it to be quiet, Default: FALSE |
Please see https://oeysan.github.io/c2z/
A list with information on the specified Zotero library (e.g., posted collections and items)
select
, bind
,
mutate
add_headers
, RETRY
toJSON, fromJSON
as_tibble
, add_column
stack
setNames
# Connect to the public group "c2z_delete" # NB! This process can be done using only `Zotero` (see README) zotero <- Zotero( user = FALSE, id = "4988497", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) # Create a new collection for POST zotero$collections <- tibble::tibble( key = ZoteroKey(), version = 0, name = "Post-test", parentCollection = "FALSE" ) # Add item to post using `ZoteroAdd` (and `ZoteroDoi`) zotero <- ZoteroAdd( zotero, doi = "10.1126/sciadv.abd1705" ) # Post a DOI to the public group "c2z_delete" post.example <- ZoteroPost( zotero, post.collections = TRUE, post.items = TRUE ) # Delete collections and items using `ZoteroDelete` delete.example <- ZoteroDelete( post.example, delete.collections = TRUE, delete.items = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(post.example$items))) { ZoteroIndex(post.example$items) |> dplyr::select(name) |> print(width = 80) }
# Connect to the public group "c2z_delete" # NB! This process can be done using only `Zotero` (see README) zotero <- Zotero( user = FALSE, id = "4988497", api = "RqlAmlH5l1KPghfCseAq1sQ1" ) # Create a new collection for POST zotero$collections <- tibble::tibble( key = ZoteroKey(), version = 0, name = "Post-test", parentCollection = "FALSE" ) # Add item to post using `ZoteroAdd` (and `ZoteroDoi`) zotero <- ZoteroAdd( zotero, doi = "10.1126/sciadv.abd1705" ) # Post a DOI to the public group "c2z_delete" post.example <- ZoteroPost( zotero, post.collections = TRUE, post.items = TRUE ) # Delete collections and items using `ZoteroDelete` delete.example <- ZoteroDelete( post.example, delete.collections = TRUE, delete.items = TRUE ) # Print index using `ZoteroIndex` if (any(nrow(post.example$items))) { ZoteroIndex(post.example$items) |> dplyr::select(name) |> print(width = 80) }
Each tibble in the list represents a zotero-item
ZoteroTypes(type = NULL, names = TRUE)
ZoteroTypes(type = NULL, names = TRUE)
type |
Type of zotero-item, Default: NULL |
names |
return only column names if set to TRUE, Default: TRUE |
A list with 36 tibbles with zero rows and various columns
Used to create Zotero-items from list of metadata
Either list of zotero-items or specified item
# All zotero-items names(ZoteroTypes()) # Column names of item-type `book` ZoteroTypes("book")
# All zotero-items names(ZoteroTypes()) # Column names of item-type `book` ZoteroTypes("book")