Package 'contribution'

Title: A Tiny Contribution Table Generator Based on 'ggplot2'
Description: Contribution table for credit assignment based on 'ggplot2'. This can improve the author contribution information in academic journals and personal CV.
Authors: Shixiang Wang [aut, cre]
Maintainer: Shixiang Wang <[email protected]>
License: MIT + file LICENSE
Version: 0.2.2
Built: 2024-08-20 02:28:54 UTC
Source: https://github.com/openbiox/contribution

Help Index


CRediT

Description

CRediT

Format

A data.frame

Source

See https://casrai.org/credit/

Examples

data("CRediT")

A demo for plotting contribution table

Description

A demo for plotting contribution table

Format

A data.frame

Source

See data_raw directory

Examples

data("demo")

Generate contribution table

Description

Generate contribution table

Usage

generate(
  data,
  color_map = c("white", "grey", "black"),
  palette_name = "github",
  sort = FALSE,
  show_legend = FALSE,
  title = NULL,
  xlab = NULL,
  ylab = NULL,
  caption = NULL,
  tag = NULL,
  font_size_x = 16,
  font_size_y = 16,
  text_angle_x = 30,
  text_angle_y = 0,
  hjust_x = 0.2,
  hjust_y = 1,
  vjust_x = 1,
  vjust_y = 0.5,
  coord_ratio = 1
)

Arguments

data

a data.frame. e.g. data("demo").

color_map

color map for discrete order, either a length-3 vector for 3 contribution level: None, Minor and Major; or a Scale object like scale_fill_brewer(palette ="Oranges").

palette_name

palette_name for plotting continuous contributions. See show_palette for available options.

sort

if TRUE, sort the plot to make sure the plot is similar what input.

show_legend

if TRUE, show figure legend.

title

The text for the title.

xlab

x axis label.

ylab

y axis label.

caption

The text for the caption which will be displayed in the bottom-right of the plot by default.

tag

The text for the tag label which will be displayed at the top-left of the plot by default.

font_size_x

font size for x.

font_size_y

font size for y.

text_angle_x

text angle for x.

text_angle_y

text angle for y.

hjust_x

hjust for x axis text.

hjust_y

hjust for y axis text.

vjust_x

vjust for x axis text.

vjust_y

vjust for y axis text.

coord_ratio

coordinate ratio.

Value

a ggplot2 object

Examples

library(contribution)
library(ggplot2)

# Paper contributions
generate(demo)
generate(demo, text_angle_x = 20, color_map = scale_fill_brewer(palette = "Oranges"))

# Github project contributions
my_contr <- dplyr::tibble(
  repo = c("UCSCXenaTools", "maftools"),
  owner = c("ShixiangWang", "PoisonAlien"),
  username = "ShixiangWang",
  role = c("Developer", "Contributor")
)

my_contr

contr_tb <- pull_github(data = my_contr)
contr_tb

generate(contr_tb, show_legend = TRUE, hjust_x = 0)
generate(contr_tb,
  show_legend = TRUE, hjust_x = 0,
  palette_name = "psychedelic"
)

palette

Description

palette

Format

A data.frame

Source

See https://github.com/williambelle/github-contribution-color-graph

Examples

data("palette")

Pull contributions from GitHub

Description

Pull contributions from GitHub

Usage

pull_github(
  data = NULL,
  repo = NULL,
  owner = NULL,
  username = NULL,
  role = NULL,
  report_lines = FALSE,
  type = c("all", "add", "del"),
  .token = NULL
)

Arguments

data

a data.frame contains columns 'repo', 'owner', 'username' and 'role'. You can also pass them one by one to the following parameters.

repo

repository name.

owner

repository owner.

username

username to pull.

role

user role in this repository.

report_lines

if TRUE, report contributed lines.

type

'all' for the sum of number of additions and deletions, 'add' for the number of additions and 'del' for the number of deletions.

.token

Authentication token. See pull_github_limit().

Value

a 'data.frameā€œ

Examples

pull_github(
  repo = "UCSCXenaTools", owner = "ShixiangWang",
  username = "ShixiangWang", role = "developer"
)

Pull GitHub API limit for current user

Description

For unauthenticated requests, the rate limit allows for up to 60 requests per hour. For API requests using Basic Authentication or OAuth, you can make up to 5000 requests per hour. Here we use token to manage this. Obtain a personal access token (PAT) from here: https://github.com/settings/tokens.

Usage

pull_github_limit(.token = NULL)

Arguments

.token

Authentication token.

Details

Typically, you can set GITHUB_PAT variable in your .Renviron file using the following format:

GITHUB_PAT=8c70fd8419398999c9ac5bacf3192882193cadf2

You can also set it in your .Rprofile file using the following format:

Sys.setenv(GITHUB_PAT="8c70fd8419398999c9ac5bacf3192882193cadf2")

For more on what to do with the PAT, see gh::gh_whoami.

Value

a list.

Examples

pull_github_limit()

Show supported palette

Description

A modified version of plot.lisa_palette.

Usage

show_palette()

Value

NULL

Examples

show_palette()