Package 'c2z'

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.2.0.9019
Built: 2025-01-05 05:03:40 UTC
Source: https://github.com/oeysan/c2z

Help Index


Search Cristin API

Description

Use search parameters for the Cristin API and return the results as a tibble. See CristinWrangler

Usage

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,
  silent = FALSE,
  base.url = "https://api.cristin.no/v2/results",
  custom.url = NULL,
  use.identifiers = TRUE,
  crossref.search = FALSE,
  autosearch = TRUE,
  zotero = NULL,
  zotero.import = TRUE,
  zotero.check = TRUE,
  nvi = FALSE,
  remove.na = TRUE,
  replace.na = "book",
  force.type = NULL,
  override = FALSE,
  polite = TRUE,
  log = list()
)

Arguments

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

silent

c2z is noisy, tell it to be quiet, Default: FALSE

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

crossref.search

Query Crossref database based on title, authors, and date if enabled, Default: FALSE

autosearch

Results could be automatically evaluated (based on some logic) or you could inspect them manually if set to FALSE, Default: TRUE

zotero

A list with information on the specified Zotero library (e.g., id, API key, collections, and items), Default: NULL

zotero.import

Use CristinWrangler to wrangle metadata into an acceptable format for Zotero, Default: TRUE

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

override

Put your faith in the algorithms and the identifiers (i.e., DOI/ISBN) and override what is reported in Cristin, Default: FALSE

polite

Please store you email in '.Renviron' to query Crossref, Default: TRUE

log

A list for storing log elements, Default: list()

Details

Please see #' https://oeysan.github.io/c2z/

Value

A list with (exported) items from Cristin

See Also

http_error, GET, RETRY tail, head slice

Examples

# 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)
  }

Check for supported export formats from Cristin to Zotero

Description

Used to filter Cristin categories that are not supported

Usage

CristinSupported(
  data = NULL,
  zotero.check = TRUE,
  items = NULL,
  remove.na = TRUE,
  replace.na = "book",
  force.type = NULL,
  remove.duplicates = TRUE,
  silent = FALSE,
  log = list()
)

Arguments

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()

Details

Please see https://oeysan.github.io/c2z/

Value

Zotero supported items with unsupported categories as NA

See Also

tibble

Examples

# Supported Cristin items
print(CristinSupported(), n = 5)

Wrangle Cristin metadata into Zotero-type format

Description

The little engine that could, at least try, to wrangle metadata from Cristin into a Zotero-type matrix. References can be augmented, or replaced with metadata gathered through ISBN or DOI identifiers, and through Crossref queries if all other fails. Or, hope the best and place your misguided faith in the ability of researchers to correctly register their own publications.

Usage

CristinWrangler(
  data,
  meta = list(),
  use.identifiers = TRUE,
  crossref.search = FALSE,
  autosearch = TRUE,
  override = FALSE,
  silent = FALSE,
  polite = TRUE,
  prefer.semantic = TRUE,
  log = list()
)

Arguments

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

crossref.search

Query Crossref database based on title, authors, and date if enabled, Default: FALSE

autosearch

Results could be automatically evaluated (based on some logic) or you could inspect them manually if set to FALSE, Default: TRUE

override

Put your faith in the algorithms and the identifiers (i.e., DOI/ISBN) and override what is reported in Cristin, Default: FALSE

silent

Running silent, running deep, Default: FALSE

polite

Please store you email in '.Renviron' to query Crossref, Default: TRUE

prefer.semantic

Prefer metadata from Semantic Scholar, Default: TRUE

log

A list for storing log elements, Default: list()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

See Also

unnest, nest filter, across, reexports, bind, mutate, distinct RETRY tibble

Examples

# Simple `Cristin` search by id with import set as FALSE
  example <- Cristin(id = "840998", zotero.import = FALSE)

  if (any(nrow(example$results))) {
    # Use `ZoteroIndex` to print `CristinWrangler`
    CristinWrangler(example$results)$results |>
      ZoteroIndex() |>
      dplyr::select(name) |>
      print(width = 80)
  }

Wrangle CrossRef metadata into Zotero-type format

Description

Query CrossRef by DOI and fetch metadata

Usage

DoiCrossref(data, meta = list(), silent = TRUE, log = list())

Arguments

data

XML data from CrossRef 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()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

Examples

# `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
  }

Wrangle DataCite metadata into Zotero-type format

Description

Query DataCite by DOI and fetch metadata

Usage

DoiDatacite(data, meta = list(), silent = TRUE, log = list())

Arguments

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()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

Examples

# `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
  }

Connect to Zotero API

Description

Wrapper to connect with the Zotero API and the main functions of *c2z*

Usage

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,
  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()
)

Arguments

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 ZoteroDoi to fetch DOI metadata, Default: NULL

isbn

Use ZoteroIsbn to fetch ISBN metadata, Default: NULL

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

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()

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., id, API key, collections, and items)

See Also

http_error, GET

Examples

# Create the default Zotero list
example <- Zotero(id = "9913421", api = "RqlAmlH5l1KPghfCseAq1sQ1")
# Print the interesting pars of an otherwise empty list
print(tail(example,5))

Add items to Zotero list

Description

Use identifiers or predefined data to add to the Zotero list

Usage

ZoteroAdd(zotero, metadata = NULL, doi = NULL, isbn = NULL, silent = FALSE)

Arguments

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 ZoteroDoi to fetch DOI metadata, Default: NULL

isbn

Use ZoteroIsbn to fetch ISBN metadata, Default: NULL

silent

c2z is noisy, tell it to be quiet, Default: FALSE

Details

Please see https://oeysan.github.io/c2z/

Value

Will add data to the Zotero list

Examples

# 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)
  }

Check Zotero library for duplicates

Description

Remove references that are not modified since last added to Zotero

Usage

ZoteroCheck(
  data,
  id,
  id.type,
  created,
  last.modified,
  items,
  remove.duplicates = TRUE,
  silent = FALSE,
  log = list()
)

Arguments

data

Tibble containing metadata (from Cristin)

id

column containing identifier (e.g., cristin_result_id)

id.type

Type of metadata as found in the Zotero extra field ("e.g., Cristin)

created

column containing creation date in UNIX timestamp format (e.g., created)

last.modified

column containing modification date in UNIX timestamp format (e.g., last_modified)

items

Items in library to check for

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()

Details

Please see https://oeysan.github.io/c2z/

Value

Returns non-duplicated data in a Zotero-type matrix (tibble)

See Also

arrange, coalesce, bind_rows, filter

Examples

# Simple `Cristin` search by id
  cristin.data <- Cristin(
    id = "840998",
    zotero.import = FALSE
  )

  # Simple `ZoteroCheck`
  example <- 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
  )

Copy collections and items from a Zotero library

Description

Replace key identifiers with new ones while keeping existing structure and relationship between collections and items

Usage

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
)

Arguments

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

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., copied collections and items)

See Also

GET mutate, case_when, filter, select, across, arrange pmap all_of

Examples

# 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)
  }

Wrangle CRAN metadata into Zotero-type format

Description

Query CRAN by name and fetch metadata

Usage

ZoteroCran(id, meta = list(), silent = TRUE, log = list())

Arguments

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()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

See Also

RETRY reexports

Examples

# 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)
  }

Delete collections and items from a Zotero library

Description

Cleaning the Zotero library

Usage

ZoteroDelete(
  zotero,
  delete.collections = FALSE,
  delete.items = FALSE,
  delete.limit = 50,
  force = FALSE,
  ragnarok = FALSE,
  silent = FALSE
)

Arguments

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

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., deleted collections and items)

See Also

add_headers, RETRY

Examples

# Delete everything in a group
  example <- ZoteroDelete(
    Zotero(
      user = FALSE,
      id = "4988497",
      api = "RqlAmlH5l1KPghfCseAq1sQ1"
    ),
    ragnarok = TRUE,
    force = TRUE
  )

Use DOI to acquire metadata

Description

Connects with doi.org to create metadata

Usage

ZoteroDoi(
  doi,
  meta = list(),
  prefer.semantic = FALSE,
  check.retraction = TRUE,
  silent = TRUE,
  log = list()
)

Arguments

doi

A digital object identifier

meta

A list collecting all metadata used to create , Default: list()

prefer.semantic

Prefer metadata from Semantic Scholar, Default: FALSE

check.retraction

Check if marked as retracted, Default: TRUE

silent

c2z is noisy, tell it to be quiet, Default: TRUE

log

A list for storing log elements, Default: list()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

See Also

http_error, GET, RETRY rename, html_attr, html_text, reexports, html_children, html_name bind, arrange

Examples

# 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)
  }

Export Zotero items to bibliography

Description

Export Zotero items to a specified format (e.g., BibLaTeX) using a CSL format (e.g., APA7)

Usage

ZoteroExport(
  zotero,
  csl.type = NULL,
  csl.name = "style",
  locale = "en-US",
  format = "biblatex",
  bib.name = "references",
  save.data = FALSE,
  save.path = NULL,
  silent = FALSE
)

Arguments

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

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., exported items, bibliography and citations)

See Also

select where

Examples

# 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

Description

Make a Zotero friendly format of input data, will add a zotero key.

Usage

ZoteroFormat(
  data = NULL,
  format = NULL,
  prefix = NULL,
  check.structure = FALSE,
  silent = FALSE
)

Arguments

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

silent

c2z is noisy, tell it to be quiet, Default: TRUE

Value

A zotero friendly tibble if requested otherwise format the data according to format.

See Also

tibble, as_tibble toJSON, fromJSON mutate_all, na_if, mutate, across, reexports, select map

Examples

ZoteroFormat(
    list(title = "This is a test", itemType = "document")
  )

Get collections and items from a Zotero library

Description

Get

Usage

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
)

Arguments

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

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., collections and items)

See Also

RETRY

Examples

# 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)
  }

Wrangle regjeringen.no metadata into Zotero-type format

Description

Query regjeringen by search word and type and fetch metadata

Usage

ZoteroGov(search, type = "NOU", meta = list(), silent = TRUE, log = list())

Arguments

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()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

See Also

RETRY reexports bind, arrange

Examples

# 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)
  }

Create an index of Zotero items

Description

The function creates a index containing key information about the present Zotero items

Usage

ZoteroIndex(data)

Arguments

data

Tibble containing Zotero-type metadata (e.g., from Cristin)

Details

Please see https://oeysan.github.io/c2z/

Value

A tibble

See Also

filter, mutate, across, na_if, case_when, arrange, group_by, context, select everything pmap

Examples

# 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)
  }

Search libraries using ISBN or MMS ID

Description

Query libraries using ISBN (or MMS ID) and fetch metadata

Usage

ZoteroIsbn(keys, meta = list(), silent = TRUE, log = list())

Arguments

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()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble)

See Also

rename, html_children, html_attr, html_text, reexports bind, distinct, arrange tibble RETRY setNames toJSON, fromJSON

Examples

# 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 Zotero key or write token

Description

Create an identifier for Zotero items/collections or a write token to library

Usage

ZoteroKey(token = FALSE)

Arguments

token

Create a write token, Default: FALSE

Details

Please see https://oeysan.github.io/c2z/

Value

Will return a 8 character Zotero key or 32 character write token

Examples

# Create a Zotero key
key <- ZoteroKey()
# Create a write token
token <- ZoteroKey(TRUE)

Access the Zotero library

Description

The function uses information stored in the 'zotero' list to access specified collections and items in the Zotero library

Usage

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
)

Arguments

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

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., collections and items)

See Also

toJSON, fromJSON distinct, arrange tibble

Examples

# 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)
  }

Search or match items using CrossRef

Description

Use the CrossRef API to match data (e.g., Cristin metadata with Crossref metadata) or search by title, authors and date

Usage

ZoteroMatch(
  title,
  authors,
  date,
  haystack = NULL,
  haystack.size = 3,
  crossref.search = FALSE,
  autosearch = FALSE,
  cristin.data = NULL,
  external.data = NULL,
  polite = TRUE,
  silent = FALSE,
  prefer.semantic = FALSE,
  log = list()
)

Arguments

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

prefer.semantic

Prefer metadata from Semantic Scholar, Default: FALSE

log

A list for storing log elements, Default: list()

Details

Please see https://oeysan.github.io/c2z/

Value

A Zotero-type matrix (tibble) if match is found otherwise NULL

See Also

select, reexports, mutate, coalesce, pull sym RETRY toJSON, fromJSON adist, head map

Examples

# 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)
  }

Post collections and items to a Zotero library

Description

Create or update collections and items in a specified library

Usage

ZoteroPost(
  zotero,
  post.collections = TRUE,
  post.items = TRUE,
  post.attachments = TRUE,
  post.limit = 50,
  force = FALSE,
  silent = FALSE
)

Arguments

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

force

Force is seldom wise, but sometimes..., Default: FALSE

silent

c2z is noisy, tell it to be quiet, Default: FALSE

Details

Please see https://oeysan.github.io/c2z/

Value

A list with information on the specified Zotero library (e.g., posted collections and items)

See Also

select, bind, mutate add_headers, RETRY toJSON, fromJSON as_tibble, add_column stack setNames

Examples

# 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)
  }

List with empty zotero-items

Description

Each tibble in the list represents a zotero-item

Usage

ZoteroTypes(type = NULL, names = TRUE)

Arguments

type

Type of zotero-item, Default: NULL

names

return only column names if set to TRUE, Default: TRUE

Format

A list with 36 tibbles with zero rows and various columns

Details

Used to create Zotero-items from list of metadata

Value

Either list of zotero-items or specified item

Examples

# All zotero-items
names(ZoteroTypes())
# Column names of item-type `book`
ZoteroTypes("book")