Skip to contents

rghcard draws cards for a GitHub profile: the contributions card, with the contributions, commits and streaks of a user, and the statistics card, with the stars, page views, clones, release downloads and GitHub Actions runs of their repositories; and four cards that take a closer look, at their activity, their visitors, their GitHub Actions runs and their code. This article starts from made-up statistics, so that everything in it runs without a token, and ends with the cards on your own profile. Draw the cards in R goes through drawing them on your computer, step by step. The contributions card, The statistics card and More cards explain each number and chart of each card, and the options that change them.

Install and load the package

install.packages("rghcard", repos = c(
  "https://sedzinfo.r-universe.dev",
  "https://cloud.r-project.org"
))

The cards

example_stats() returns the statistics of a made-up user, example-user, with eight repositories, 30 days of traffic and contributions since March 2019:

stats <- example_stats()
stats
#> GitHub statistics of example-user, collected until 2026-12-03
#> 8 repositories, 101 stars, traffic from 2026-11-03 to 2026-12-02, 4,132 contributions since 2019-03-14
#> Tables: repos (8 rows), views (240 rows), clones (240 rows), traffic (8 rows), referrers (12 rows), pages (9 rows), releases (4 rows), actions (87 rows), languages (15 rows), stars (101 rows), profile (1 rows), contributions (2822 rows), commits (69 rows), contribution_types (8 rows)

contributions_card() draws their contributions, as an SVG or a PNG file:

contributions_card(stats, "contributions.svg")
GitHub contributions of example-user Contributions: 4.1K (since Mar 2019), Last 12 months: 1.2K (contributions), Commits: 2.5K (public repositories), Current streak: 23 days (since 10 Nov), Longest streak: 41 days (7 Apr – 17 May 2025), 14 Mar 2019 – 3 Dec 2026.example-user· GitHub contributions14 Mar 2019 – 3 Dec 2026Contributions4.1Ksince Mar 2019Last 12 months1.2KcontributionsCommits2.5Kpublic repositoriesCurrent streak23 dayssince 10 NovLongest streak41 days7 Apr – 17 May 2025Contributionsper month, Dec 2025 – Nov 2026050100150200Dec 2025: 53 contributionsJan 2026: 94 contributionsFeb 2026: 72 contributionsMar 2026: 117 contributionsApr 2026: 97 contributionsMay 2026: 82 contributionsJun 2026: 123 contributionsJul 2026: 146 contributionsAug 2026: 57 contributionsSep 2026: 113 contributionsOct 2026: 94 contributionsNov 2026: 162 contributions162Dec 2025Nov 2026Languages by commitscommits per repository languageR: 1,781 commits (71.8%)Python: 267 commits (10.8%)HTML: 205 commits (8.3%)TeX: 155 commits (6.3%)Shell: 71 commits (2.9%)2.5KcommitsR71.8%Python10.8%HTML8.3%TeX6.3%Shell2.9%Languages by repositoriesrepositories per main languageR: 4 repositories (50%)HTML: 1 repository (12.5%)Python: 1 repository (12.5%)Shell: 1 repository (12.5%)TeX: 1 repository (12.5%)8repositoriesR50%HTML12.5%Python12.5%Shell12.5%TeX12.5%Contributions as the contribution graph of the GitHub profile counts them.rghcard · updated 3 Dec 2026

Its key figures are the contributions since joining GitHub and in the last 12 months, the commits, and the current and the longest streak of days with contributions. Under them are the contributions per month and the languages by commits and by repositories. The contributions card explains each of them.

stats_card() draws the statistics of their repositories:

stats_card(stats, "stats.svg")
GitHub statistics of example-user Repositories: 8 (public), Stars: 101 (total), Page views: 1.1K (last 30 days), Clones: 1.4K (last 30 days), Release downloads: 599 (all time), Actions runs: 86 (last 30 days), 3 Nov – 2 Dec 2026.example-user· GitHub statistics3 Nov – 2 Dec 2026Repositories8publicStars101totalPage views1.1Klast 30 daysClones1.4Klast 30 daysRelease downloads599all timeActions runs86last 30 daysPage viewsper day, last 30 days0204060801003 Nov 2026: 47 page views4 Nov 2026: 30 page views5 Nov 2026: 26 page views6 Nov 2026: 53 page views7 Nov 2026: 22 page views8 Nov 2026: 9 page views9 Nov 2026: 37 page views10 Nov 2026: 38 page views11 Nov 2026: 33 page views12 Nov 2026: 32 page views13 Nov 2026: 29 page views14 Nov 2026: 14 page views15 Nov 2026: 20 page views16 Nov 2026: 52 page views17 Nov 2026: 36 page views18 Nov 2026: 40 page views19 Nov 2026: 39 page views20 Nov 2026: 82 page views21 Nov 2026: 23 page views22 Nov 2026: 15 page views23 Nov 2026: 43 page views24 Nov 2026: 55 page views25 Nov 2026: 39 page views26 Nov 2026: 37 page views27 Nov 2026: 61 page views28 Nov 2026: 16 page views29 Nov 2026: 22 page views30 Nov 2026: 33 page views1 Dec 2026: 47 page views2 Dec 2026: 42 page views823 Nov2 DecClonesper day, last 30 days0501003 Nov 2026: 51 clones4 Nov 2026: 68 clones5 Nov 2026: 51 clones6 Nov 2026: 57 clones7 Nov 2026: 25 clones8 Nov 2026: 24 clones9 Nov 2026: 43 clones10 Nov 2026: 66 clones11 Nov 2026: 67 clones12 Nov 2026: 48 clones13 Nov 2026: 60 clones14 Nov 2026: 25 clones15 Nov 2026: 22 clones16 Nov 2026: 62 clones17 Nov 2026: 65 clones18 Nov 2026: 58 clones19 Nov 2026: 48 clones20 Nov 2026: 86 clones21 Nov 2026: 19 clones22 Nov 2026: 22 clones23 Nov 2026: 48 clones24 Nov 2026: 65 clones25 Nov 2026: 45 clones26 Nov 2026: 48 clones27 Nov 2026: 41 clones28 Nov 2026: 19 clones29 Nov 2026: 19 clones30 Nov 2026: 64 clones1 Dec 2026: 58 clones2 Dec 2026: 52 clones863 Nov2 DecMost viewed repositoriespage views, last 30 daystidysurveytidysurvey: 434 page views434plotkitplotkit: 202 page views202shiny-weathershiny-weather: 143 page views143websitewebsite: 114 page views114workshop-2026workshop-2026: 88 page views88Clones include automated ones: GitHub Actions runs, package builders, app deployments.rghcard · updated 3 Dec 2026

Its key figures are the repositories and their stars, the page views and clones of the last 30 days, the downloads of release files and the GitHub Actions runs. Under them are the page views and clones per day, with the busiest day labelled, and the most viewed repositories. The statistics card explains each of them, and how to choose other charts and another period.

In an SVG shown in a web page, as here, each column and bar tells its value when you point at it. view_card() shows a card that way in the Viewer pane of RStudio or Positron, and as a picture in the Plots pane:

view_card("stats.svg")
view_card("stats.svg", "plots")

Four more cards take a closer look, each with its own key figures and charts:

  • activity_card(): the pull requests, issues, reviews and new repositories of the user, their followers, their contributions by type and by day of the week, and the repositories they commit to most.
  • visitors_card(): the unique visitors and cloners of their repositories in the last 14 days, the sites that sent them and the pages they viewed.
  • actions_card(): their GitHub Actions runs, how many succeeded and failed, how long they took and the busiest workflows.
  • code_card(): the size of their code in each language, their largest repositories, their stars month by month, and their forks and watchers.
activity_card(stats, "activity.svg")
GitHub activity of example-user Pull requests: 654 (since Mar 2019), Issues: 474 (since Mar 2019), Reviews: 356 (since Mar 2019), New repositories: 14 (since Mar 2019), Followers: 87 (following 41), 14 Mar 2019 – 3 Dec 2026.example-user· GitHub activity14 Mar 2019 – 3 Dec 2026Pull requests654since Mar 2019Issues474since Mar 2019Reviews356since Mar 2019New repositories14since Mar 2019Followers87following 41Contributions by typesince Mar 2019Commits: 2,479 contributions (60%)Pull requests: 654 contributions (15.8%)Issues: 474 contributions (11.5%)Reviews: 356 contributions (8.6%)Private: 155 contributions (3.8%)4.1KcontributionsCommits60%Pull requests15.8%Issues11.5%Reviews8.6%New repos0.3%Private3.8%Contributions by weekdayper weekday, Dec 2025 – Nov 20260100200300Mon: 180 contributionsTue: 210 contributionsWed: 234 contributionsThu: 184 contributionsFri: 214 contributionsSat: 85 contributionsSun: 103 contributions234MonTueWedThuFriSatSunMost committed repositoriescommits, since Mar 2019tidysurveytidysurvey: 783 commits783plotkitplotkit: 455 commits455shiny-weathershiny-weather: 270 commits270pyscriptspyscripts: 267 commits267websitewebsite: 205 commits205Contributions as the contribution graph of the GitHub profile counts them.rghcard · updated 3 Dec 2026

More cards shows the four and explains each of their numbers and charts. Any card can also show the charts of any other.

Dark or light

theme = "light" draws a card in the colours of GitHub’s light mode:

contributions_card(stats, "contributions-light.svg", theme = "light")
GitHub contributions of example-user Contributions: 4.1K (since Mar 2019), Last 12 months: 1.2K (contributions), Commits: 2.5K (public repositories), Current streak: 23 days (since 10 Nov), Longest streak: 41 days (7 Apr – 17 May 2025), 14 Mar 2019 – 3 Dec 2026.example-user· GitHub contributions14 Mar 2019 – 3 Dec 2026Contributions4.1Ksince Mar 2019Last 12 months1.2KcontributionsCommits2.5Kpublic repositoriesCurrent streak23 dayssince 10 NovLongest streak41 days7 Apr – 17 May 2025Contributionsper month, Dec 2025 – Nov 2026050100150200Dec 2025: 53 contributionsJan 2026: 94 contributionsFeb 2026: 72 contributionsMar 2026: 117 contributionsApr 2026: 97 contributionsMay 2026: 82 contributionsJun 2026: 123 contributionsJul 2026: 146 contributionsAug 2026: 57 contributionsSep 2026: 113 contributionsOct 2026: 94 contributionsNov 2026: 162 contributions162Dec 2025Nov 2026Languages by commitscommits per repository languageR: 1,781 commits (71.8%)Python: 267 commits (10.8%)HTML: 205 commits (8.3%)TeX: 155 commits (6.3%)Shell: 71 commits (2.9%)2.5KcommitsR71.8%Python10.8%HTML8.3%TeX6.3%Shell2.9%Languages by repositoriesrepositories per main languageR: 4 repositories (50%)HTML: 1 repository (12.5%)Python: 1 repository (12.5%)Shell: 1 repository (12.5%)TeX: 1 repository (12.5%)8repositoriesR50%HTML12.5%Python12.5%Shell12.5%TeX12.5%Contributions as the contribution graph of the GitHub profile counts them.rghcard · updated 3 Dec 2026

On a GitHub profile, a <picture> element shows each reader the card of their mode (see On your GitHub profile).

Your own statistics

collect_stats() reads the statistics of the repositories you own and your contributions, and adds them to a history of CSV files, in rghcard-data/ by default:

stats <- collect_stats()
contributions_card(stats, "rghcard-contributions.svg")
stats_card(stats, "rghcard-stats.svg")

GitHub shows the page views and clones of a repository only to those who can push to it, so collect_stats() reads them with a token of yours, which the gh package finds in the GITHUB_PAT environment variable or in the git credential store; Draw the cards in R shows how to put one there. A fine-grained token needs the permission Administration: Read-only, a classic one the repo scope. A fine-grained token, though, leaves out your private contributions, which your profile may show as bare numbers: contributions_token reads them with another token, such as a classic one. The rghcard action reads them with the token of its workflow, which sees your profile as others see it.

GitHub keeps the traffic for 14 days, so run collect_stats() at least once a week: each run adds the new days to the history, and the card can then cover more than 14 days. read_stats() reads the history again, without asking GitHub:

stats <- read_stats("rghcard-data")

The history has a table for each kind of statistic, each a CSV file: repos (stars, forks, watchers, open issues, size, language and last push of each repository on each day of collection), views and clones (per repository and day), traffic, referrers and pages (the totals, the referring sites and the most viewed pages of the 14 days that GitHub gives, on each day of collection), releases (downloads of each release file), actions (one row per run), languages (the bytes of code of each repository in each language), stars (the time of each star), profile (the followers, and the users followed, on each day of collection), contributions (per day since joining GitHub), commits (per repository and year) and contribution_types (per year and type). The help page of collect_stats() describes each. Each collection reads the contributions, the commits and their types whole, from GitHub’s GraphQL API, which answers any token but none without one.

Private repositories and forks are left out, since the cards and their history are usually public; include_private = TRUE and include_forks = TRUE bring them in.

For another user, collect_stats() collects the public statistics only: repositories, stars, forks, languages, release downloads, GitHub Actions runs and contributions. Their statistics card then shows other figures and charts, which The statistics card shows, and Cards from a user name draws the cards of any user from their user name, in R or in a Shiny app.

# dir = NULL keeps nothing on disk
octocat <- collect_stats(user = "octocat", dir = NULL)
contributions_card(octocat, "octocat-contributions.svg")
stats_card(octocat, "octocat-stats.svg")

On your GitHub profile

GitHub shows on your profile the README of the repository named after your user name. A GitHub Actions workflow in that repository can refresh the cards every week: it runs rghcard’s GitHub Action, which installs R and rghcard on GitHub’s machine, so it needs no R on your computer. use_rghcard_action() writes the workflow into a copy of the repository on your computer, and lists the next steps:

use_rghcard_action("path/to/your/profile/repository")
  1. Create a fine-grained token with this link, which fills in GitHub’s form: the name rghcard, the permission Administration: Read-only and Expiration: none, since the cards stop updating when the token expires. GitHub adds Metadata: Read-only by itself. Choose Repository access: All repositories, click Generate token and copy the token: GitHub shows it only once.

  2. In the profile repository, Settings > Secrets and variables > Actions > New repository secret: name it RGHCARD_TOKEN and paste the token.

  3. Commit and push the workflow, then run it once: Actions > rghcard > Run workflow.

  4. Add the cards you want to README.md, each in a <picture> like these two; the other cards are activity, visitors, actions and code, and use_rghcard_action() prints the code of every card it draws:

    <picture>
      <source media="(prefers-color-scheme: dark)"
              srcset="rghcard-contributions-dark.svg"/>
      <img alt="GitHub contributions" src="rghcard-contributions-light.svg"
           width="100%"/>
    </picture>
    <picture>
      <source media="(prefers-color-scheme: dark)"
              srcset="rghcard-stats-dark.svg"/>
      <img alt="GitHub statistics" src="rghcard-stats-light.svg"
           width="100%"/>
    </picture>

Every Monday at 05:17 UTC (schedule changes when), the workflow runs the action of the latest release of rghcard 0.x, sedzinfo/rghcard@v0: it collects your statistics, draws the six cards (cards chooses which) in the dark and the light theme (themes chooses), as SVG files (format chooses), and commits them with the history in rghcard-data/. The inputs of the action, under with: in the workflow, change the cards: their charts and days, for example. The README lists them.

When the token expires or is revoked, the run fails with a message saying so: put a new token in the secret. In a public profile repository, all of it is public: the page views, clones and unique visitors of each repository per day, with its top referring sites and most viewed pages; the downloads of each release file; your GitHub Actions runs, with their times; the bytes of code of each repository in each language and the time of each star; how many followers you have, and how many users you follow; your contributions per day and by type (which your profile shows anyway) and your commits per repository and year. Who visits, clones or stars your repositories is never collected.