pakret

Cite R packages on the fly in R Markdown and Quarto

https://github.com/arnaudgallou/pakret

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.5%) to scientific vocabulary

Keywords

bib bibtex citation citations generate
Last synced: 6 months ago · JSON representation

Repository

Cite R packages on the fly in R Markdown and Quarto

Basic Info
Statistics
  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • Open Issues: 1
  • Releases: 4
Topics
bib bibtex citation citations generate
Created over 1 year ago · Last pushed 11 months ago
Metadata Files
Readme Changelog License

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

options(pakret.render_mode = FALSE)

make_template <- function(lines, to_render = TRUE) {
  if (to_render) {
    args <- list("%s", "`r pakret:::load_foo()` `r pakret:::load_bar()`")
  } else {
    args <- list("references.bib", "")
  }
  do.call(sprintf, c(lines, args))
}
```

# pakret


[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/pakret)](https://CRAN.R-project.org/package=pakret)
[![R-CMD-check](https://github.com/arnaudgallou/pakret/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/arnaudgallou/pakret/actions/workflows/R-CMD-check.yaml)


## Overview

pakret is a minimalistic R package citation tool to reference and cite R and R packages on the fly in R Markdown and Quarto.

## Installation

Install pakret from CRAN with:

```{r, eval = FALSE}
install.packages("pakret")
```

Alternatively, you can install the development version of pakret from GitHub with:

```{r, eval = FALSE}
# install.packages("pak")
pak::pak("arnaudgallou/pakret")
```

## Usage

Simply use `pkrt()` whenever you want to cite R or an R package in your document:

````{r, include = FALSE}
template <- pakret:::dedent('
  ---
  bibliography: %s
  ---

  ```{r}
  #| include: false
  library(pakret)
  ```
  %s
  We used `r pkrt("foo")` to extract the data.

  Analyses were performed using `r pkrt("bar")`.

  ## References
')
````

```{r, echo = FALSE, class.output = "default"}
cat(make_template(template, FALSE))
```

pakret handles everything for you.

Here’s the markdown output produced by the document above:

```{r, echo = FALSE}
make_template(template) |>
  pakret:::local_files() |>
  pakret:::read_local_file() |>
  cat()
```

It's also possible to cite a collection of packages with `pkrt_list()`:

````{r, include = FALSE}
template <- pakret:::dedent('
  ---
  bibliography: %s
  ---

  ```{r}
  #| include: false
  library(pakret)
  ```
  %s
  I used the following packages: `r pkrt_list("foo", "bar")`.

  ## References
')
````

```{r, echo = FALSE, class.output = "default"}
cat(make_template(template, FALSE))
```



```{r, echo = FALSE}
make_template(template) |>
  pakret:::local_files() |>
  pakret:::read_local_file() |>
  cat()
```

Unhappy with the default templates? pakret lets you define your own:

````{r, include = FALSE}
template <- pakret:::dedent('
  ---
  bibliography: %s
  ---

  ```{r}
  #| include: false

  library(pakret)
  pkrt_set(pkg = "the R package *:pkg* [v. :ver, :ref]")
  ```
  %s
  We used `r pkrt("foo")` to analyse the data.

  ## References
')
````

```{r, echo = FALSE, class.output = "default"}
cat(make_template(template, FALSE))
```



```{r, echo = FALSE}
make_template(template) |>
  pakret:::local_files() |>
  pakret:::read_local_file() |>
  cat()
```

Note that by default pakret writes new references into the first `.bib` file specified in the bibliography list.
You can change which `.bib` file to save references to using `pkrt_set()`.

Owner

  • Name: Arnaud Gallou
  • Login: arnaudgallou
  • Kind: user

GitHub Events

Total
  • Create event: 12
  • Release event: 1
  • Issues event: 9
  • Delete event: 12
  • Push event: 35
  • Pull request event: 20
Last Year
  • Create event: 12
  • Release event: 1
  • Issues event: 9
  • Delete event: 12
  • Push event: 35
  • Pull request event: 20

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 1
  • Total pull requests: 8
  • Average time to close issues: about 11 hours
  • Average time to close pull requests: about 2 hours
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 8
  • Average time to close issues: about 11 hours
  • Average time to close pull requests: about 2 hours
  • Issue authors: 1
  • Pull request authors: 1
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.0
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • arnaudgallou (9)
Pull Request Authors
  • arnaudgallou (24)
Top Labels
Issue Labels
enhancement (2) bug (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 549 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 4
  • Total maintainers: 1
cran.r-project.org: pakret

Cite 'R' Packages on the Fly in 'R Markdown' and 'Quarto'

  • Versions: 4
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 549 Last month
Rankings
Dependent packages count: 28.3%
Dependent repos count: 34.9%
Average: 50.0%
Downloads: 86.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
.github/workflows/pkgdown.yaml actions
  • JamesIves/github-pages-deploy-action v4.5.0 composite
  • actions/checkout v4 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 3.6.0 depends
  • readr >= 1.0.0 imports
  • rmarkdown * imports
  • utils * imports
  • withr >= 2.5.0 imports
  • callr >= 3.7.5 suggests
  • knitr * suggests
  • pkgload * suggests
  • testthat >= 3.0.0 suggests
  • usethis * suggests