| Title: | Easy Reference Generation for R Packages |
|---|---|
| Description: | Generate citations and references for R packages from CRAN or Bioconductor. Supports RIS and BibTeX formats with automatic DOI retrieval from GitHub repositories and published papers. Includes command-line interface for batch processing. |
| Authors: | Rasmus Rydbirk [aut, cre] |
| Maintainer: | Rasmus Rydbirk <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-06-08 07:22:08 UTC |
| Source: | https://github.com/rrydbirk/easyref |
Extract authors from bibentry object
authors_from_bibentry(be)authors_from_bibentry(be)
be |
Bibentry object |
Character vector of author names
Convert bibentry to BibTeX string
bibtex_from_bibentry(be, key_hint = NULL)bibtex_from_bibentry(be, key_hint = NULL)
be |
Bibentry object |
key_hint |
Optional key hint (not used currently) |
BibTeX string or NULL if conversion fails
Get Bioconductor metadata for a package without installing it
bioc_meta_for(pkg)bioc_meta_for(pkg)
pkg |
Package name |
List with package metadata or NULL if not found
Clean author names by removing bracketed content
clean_author_name(x)clean_author_name(x)
x |
Author name string |
Cleaned author name string
Collect package information and generate citations (internal)
collect_for_package_internal(pkg, database = "auto", verbose = FALSE)collect_for_package_internal(pkg, database = "auto", verbose = FALSE)
pkg |
Package name |
database |
Repository to search: "auto", "cran", or "bioconductor" |
verbose |
Logical. If TRUE, prints detailed information about each step |
List with package information and formatted citations
Get CRAN metadata for a package without installing it
cran_meta_for(pkg)cran_meta_for(pkg)
pkg |
Package name |
List with package metadata or NULL if not found
Creates a properly formatted BibTeX citation entry for software packages.
createBibtex( key, title, authors, year, url = NULL, version = NULL, filename = NULL, overwrite = TRUE )createBibtex( key, title, authors, year, url = NULL, version = NULL, filename = NULL, overwrite = TRUE )
key |
BibTeX key for the entry |
title |
Software title |
authors |
Character vector of author names |
year |
Publication year |
url |
Software URL (optional) |
version |
Software version (optional) |
filename |
Output file path. If NULL, returns the BibTeX string without writing to file |
overwrite |
Allow overwriting existing files (default: TRUE) |
Character string with BibTeX formatted citation, or writes to file if filename provided
createBibtex( key = "ggplot2_2016", title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", url = "https://ggplot2.tidyverse.org", filename = tempfile() # Omit filename ) # Write to file createBibtex( key = "ggplot2_2016", title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", filename = tempfile() # Replace with e.g. "ggplot2.bib" )createBibtex( key = "ggplot2_2016", title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", url = "https://ggplot2.tidyverse.org", filename = tempfile() # Omit filename ) # Write to file createBibtex( key = "ggplot2_2016", title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", filename = tempfile() # Replace with e.g. "ggplot2.bib" )
Convenience function specifically for Bioconductor packages. Automatically detects Bioconductor packages and retrieves metadata from Bioconductor repositories.
createBiocRef( pkg, format = "ris", filename = NULL, overwrite = TRUE, verbose = FALSE, database = "auto" )createBiocRef( pkg, format = "ris", filename = NULL, overwrite = TRUE, verbose = FALSE, database = "auto" )
pkg |
Character vector of Bioconductor package names to process |
format |
Output format: "ris", "bib", "bibtex", or "both" (default: "ris") |
filename |
Output file path. If NULL, creates a default filename based on package name(s). If no file extension is provided, one will be added based on the format. |
overwrite |
Allow overwriting existing files (default: TRUE) |
verbose |
Logical. If TRUE, prints detailed information about each step (default: FALSE) |
database |
Repository to search: "auto" (default), "cran", or "bioconductor". For Bioconductor packages, "bioconductor" is recommended. |
Invisible list of results with package information and formatted citations. Always writes to file.
# Generate citation for Bioconductor packages (requires BiocManager) if (requireNamespace("BiocManager", quietly = TRUE)) { result <- createBiocRef("Biobase", filename = tempfile()) # Generate citations for multiple Bioconductor packages bioc_packages <- c("Biobase", "limma", "edgeR") results <- createBiocRef(bioc_packages, format = "both", filename = tempfile()) # Omit filename # Write Bioconductor package citations to file (extension added automatically) createBiocRef("Biobase", filename = tempfile()) # Replace with e.g. "biobase_citation" # Verbose output for Bioconductor packages (writes to default file) createBiocRef("Biobase", verbose = TRUE, filename = tempfile()) # Omit filename = tempfile() # Force search in Bioconductor repository createBiocRef("Biobase", database = "bioconductor", verbose = TRUE, filename = tempfile()) # Omit filename = tempfile() }# Generate citation for Bioconductor packages (requires BiocManager) if (requireNamespace("BiocManager", quietly = TRUE)) { result <- createBiocRef("Biobase", filename = tempfile()) # Generate citations for multiple Bioconductor packages bioc_packages <- c("Biobase", "limma", "edgeR") results <- createBiocRef(bioc_packages, format = "both", filename = tempfile()) # Omit filename # Write Bioconductor package citations to file (extension added automatically) createBiocRef("Biobase", filename = tempfile()) # Replace with e.g. "biobase_citation" # Verbose output for Bioconductor packages (writes to default file) createBiocRef("Biobase", verbose = TRUE, filename = tempfile()) # Omit filename = tempfile() # Force search in Bioconductor repository createBiocRef("Biobase", database = "bioconductor", verbose = TRUE, filename = tempfile()) # Omit filename = tempfile() }
This is the main function to collect information about R packages and generate citations in RIS or BibTeX format. Supports both CRAN and Bioconductor packages with automatic DOI retrieval from GitHub repositories and published papers.
createRef( pkg, format = "ris", filename = NULL, overwrite = TRUE, verbose = FALSE, database = "auto" )createRef( pkg, format = "ris", filename = NULL, overwrite = TRUE, verbose = FALSE, database = "auto" )
pkg |
Character vector of package names to process |
format |
Output format: "ris", "bib", "bibtex", or "both" (default: "ris") |
filename |
Output file path. If NULL, creates a default filename based on package name(s). If no file extension is provided, one will be added based on the format. |
overwrite |
Allow overwriting existing files (default: TRUE) |
verbose |
Logical. If TRUE, prints detailed information about each step (default: FALSE) |
database |
Repository to search: "auto" (default), "cran", or "bioconductor". "auto" automatically detects the repository, "cran" searches only CRAN, "bioconductor" searches only Bioconductor. |
Invisible list of results with package information and formatted citations. Always writes to file.
# Generate RIS citation for a CRAN package result <- createRef("ggplot2", filename = tempfile()) # Omit filename # Generate citation for a Bioconductor package (requires BiocManager) if (requireNamespace("BiocManager", quietly = TRUE)) { result <- createRef("Biobase", filename = tempfile()) } # Generate both RIS and BibTeX for multiple packages results <- createRef(c("ggplot2", "dplyr"), format = "both", filename = tempfile()) # Write to file (extension will be added automatically) createRef("ggplot2", filename = tempfile()) # Replace with e.g. "ggplot2_citation" # Verbose output showing each step (writes to default file) createRef("ggplot2", verbose = TRUE, filename = tempfile()) # Omit filename # Force search in specific repository createRef("ggplot2", database = "cran", filename = tempfile()) # Omit filename# Generate RIS citation for a CRAN package result <- createRef("ggplot2", filename = tempfile()) # Omit filename # Generate citation for a Bioconductor package (requires BiocManager) if (requireNamespace("BiocManager", quietly = TRUE)) { result <- createRef("Biobase", filename = tempfile()) } # Generate both RIS and BibTeX for multiple packages results <- createRef(c("ggplot2", "dplyr"), format = "both", filename = tempfile()) # Write to file (extension will be added automatically) createRef("ggplot2", filename = tempfile()) # Replace with e.g. "ggplot2_citation" # Verbose output showing each step (writes to default file) createRef("ggplot2", verbose = TRUE, filename = tempfile()) # Omit filename # Force search in specific repository createRef("ggplot2", database = "cran", filename = tempfile()) # Omit filename
Creates a properly formatted RIS citation entry for software packages.
createRis( title, authors, year, url = NULL, version = NULL, doi = NULL, notes = NULL, publisher = "Comprehensive R Archive Network (CRAN)", filename = NULL, overwrite = TRUE )createRis( title, authors, year, url = NULL, version = NULL, doi = NULL, notes = NULL, publisher = "Comprehensive R Archive Network (CRAN)", filename = NULL, overwrite = TRUE )
title |
Software title |
authors |
Character vector of author names |
year |
Publication year |
url |
Software URL (optional) |
version |
Software version (optional) |
doi |
DOI (optional) |
notes |
Additional notes (optional) |
publisher |
Publisher name (default: "Comprehensive R Archive Network (CRAN)") |
filename |
Output file path. If NULL, returns the RIS string without writing to file |
overwrite |
Allow overwriting existing files (default: TRUE) |
Character string with RIS formatted citation, or writes to file if filename provided
createRis( title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", url = "https://ggplot2.tidyverse.org", filename = tempfile() # Omit filename ) # Write to file createRis( title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", filename = tempfile() # Replace with e.g. "ggplot2.ris" )createRis( title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", url = "https://ggplot2.tidyverse.org", filename = tempfile() # Omit filename ) # Write to file createRis( title = "ggplot2: Create Elegant Data Visualisations", authors = c("Wickham, Hadley"), year = "2016", filename = tempfile() # Replace with e.g. "ggplot2.ris" )
Emit citation outputs in specified formats (internal)
emit_outputs_internal(results, format, out, split, overwrite)emit_outputs_internal(results, format, out, split, overwrite)
results |
List of package citation results |
format |
Output format: "ris", "bib", "bibtex", or "both" |
out |
Output file path or directory |
split |
Write one file per package when multiple packages or format="both" |
overwrite |
Allow overwriting existing files |
Invisible TRUE
Ensure directory exists
ensure_dir(path)ensure_dir(path)
path |
Directory path |
Extract DOI from reference sections in README content
extract_doi_from_reference_sections(readme_content)extract_doi_from_reference_sections(readme_content)
readme_content |
Character vector of README lines |
DOI string or NULL if not found
Get author information from BioC package website
get_bioc_author_from_web(pkg)get_bioc_author_from_web(pkg)
pkg |
Package name |
Character string with author information or NULL if not available
Get author information from CRAN package website
get_cran_author_from_web(pkg)get_cran_author_from_web(pkg)
pkg |
Package name |
Character string with author information or NULL if not available
Get title information from CRAN package website
get_cran_title_from_web(pkg)get_cran_title_from_web(pkg)
pkg |
Package name |
Character string with title information or NULL if not available
Get DOI from GitHub repository
get_doi_from_github(repo)get_doi_from_github(repo)
repo |
GitHub repository in format "owner/repo" |
DOI string or NULL if not found
Get DOI from package citation or metadata
get_doi_from_package(pkg)get_doi_from_package(pkg)
pkg |
Package name |
DOI string or NULL if not found
Get GitHub repository information and DOI
get_github_info(pkg, url = NULL)get_github_info(pkg, url = NULL)
pkg |
Package name |
url |
Package URL (optional) |
List with GitHub info and DOI or NULL if not found
Generate CRAN/Bioconductor DOI for a package
get_repository_doi(pkg, repository)get_repository_doi(pkg, repository)
pkg |
Package name |
repository |
Repository name ("CRAN" or "Bioconductor") |
DOI string or NULL if not found
Check if a package is from Bioconductor
is_bioc_package(pkg)is_bioc_package(pkg)
pkg |
Package name |
Logical indicating if package is from Bioconductor
Check if a package is installed
is_installed(pkg)is_installed(pkg)
pkg |
Package name to check |
Logical indicating if package is installed
Generate RIS format citation for software (internal)
make_ris_for_software_internal( title, authors, year, url = NULL, version = NULL, doi = NULL, notes = NULL, publisher = "Comprehensive R Archive Network (CRAN)" )make_ris_for_software_internal( title, authors, year, url = NULL, version = NULL, doi = NULL, notes = NULL, publisher = "Comprehensive R Archive Network (CRAN)" )
title |
Software title |
authors |
Character vector of author names |
year |
Publication year |
url |
Software URL (optional) |
version |
Software version (optional) |
doi |
DOI (optional) |
notes |
Additional notes (optional) |
publisher |
Publisher name (default: "Comprehensive R Archive Network (CRAN)") |
Character string with RIS formatted citation
Normalize string for use as BibTeX key
normalize_key(x)normalize_key(x)
x |
String to normalize |
Normalized string
Check if a package exists on CRAN or Bioconductor repositories
package_exists_on_repos(pkg)package_exists_on_repos(pkg)
pkg |
Package name |
Logical indicating if package exists on any repository
Parse author text from DESCRIPTION file
parse_author_text(x)parse_author_text(x)
x |
Author text string |
Character vector of author names
Convert person object to string format
person_to_string(p)person_to_string(p)
p |
Person object |
Character string with formatted name
Sanitize text for RIS format (single-line)
ris_sanitize(x)ris_sanitize(x)
x |
Text to sanitize |
Sanitized text
Safely get element from list with default value
safely_get(x, name, default = NULL)safely_get(x, name, default = NULL)
x |
List or object to access |
name |
Name of element to get |
default |
Default value if element doesn't exist |
Element value or default
Generate BibTeX format citation for software (internal)
synthesize_bibtex_internal( key, title, authors, year, url = NULL, version = NULL, doi = NULL )synthesize_bibtex_internal( key, title, authors, year, url = NULL, version = NULL, doi = NULL )
key |
BibTeX key for the entry |
title |
Software title |
authors |
Character vector of author names |
year |
Publication year |
url |
Software URL (optional) |
version |
Software version (optional) |
doi |
DOI (optional) |
Character string with BibTeX formatted citation
Try case-insensitive search for package name
try_case_insensitive_search(pkg, database, verbose = FALSE)try_case_insensitive_search(pkg, database, verbose = FALSE)
pkg |
Package name to search for |
database |
Repository to search: "auto", "cran", or "bioconductor" |
verbose |
Logical. If TRUE, prints detailed information |
List with origin and correct_name if found, NULL otherwise
Write text to file with overwrite control
write_text(path, text, overwrite = FALSE)write_text(path, text, overwrite = FALSE)
path |
File path |
text |
Text to write |
overwrite |
Whether to allow overwriting existing files |
Extract year from bibentry object
year_from_bibentry(be)year_from_bibentry(be)
be |
Bibentry object |
Character string with year