Skip to contents

Give rghcard a GitHub user name, and it draws the cards of that user: it reads their statistics from GitHub and draws them, in a few lines of R. This article shows how, for your user name or anyone’s: in the console, in a function of your own and in a Shiny app, where anyone can type a user name and see the card.

Draw the cards in R installs rghcard. The cards in this article are those of example-user, the made-up user of example_stats(), so that the article runs without asking GitHub; a user name brings cards like them.

A user name in, a card out

library(rghcard)
user <- "octocat"   # your GitHub user name
stats <- collect_stats(user = user, dir = NULL)
view_card(stats_card(stats, file = NULL))
GitHub statistics of example-user Repositories: 8 (public), Stars: 101 (total), Forks: 19 (total), Release downloads: 599 (all time), Actions runs: 86 (last 30 days), 3 Nov – 2 Dec 2026.example-user· GitHub statistics3 Nov – 2 Dec 2026Repositories8publicStars101totalForks19totalRelease downloads599all timeActions runs86last 30 daysGitHub Actions runsper day, last 30 days024683 Nov 2026: 3 runs4 Nov 2026: 7 runs5 Nov 2026: 2 runs6 Nov 2026: 4 runs7 Nov 2026: 1 run8 Nov 2026: 2 runs9 Nov 2026: 2 runs10 Nov 2026: 4 runs12 Nov 2026: 2 runs13 Nov 2026: 4 runs14 Nov 2026: 2 runs15 Nov 2026: 1 run16 Nov 2026: 3 runs17 Nov 2026: 5 runs18 Nov 2026: 2 runs19 Nov 2026: 7 runs20 Nov 2026: 3 runs21 Nov 2026: 2 runs22 Nov 2026: 2 runs23 Nov 2026: 4 runs25 Nov 2026: 3 runs26 Nov 2026: 4 runs27 Nov 2026: 2 runs28 Nov 2026: 2 runs29 Nov 2026: 4 runs30 Nov 2026: 3 runs1 Dec 2026: 3 runs2 Dec 2026: 3 runs73 Nov2 DecMost starred repositoriesstarstidysurveytidysurvey: 48 stars48plotkitplotkit: 23 stars23shiny-weathershiny-weather: 12 stars12workshop-2026workshop-2026: 7 stars7pyscriptspyscripts: 5 stars5Languages 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%rghcard · updated 3 Dec 2026

collect_stats() reads the statistics of the user from GitHub, and dir = NULL keeps nothing on disk. stats_card() draws the statistics card, and file = NULL returns it as SVG code instead of a file. view_card() shows it in the Viewer pane of RStudio or Positron, or in your web browser elsewhere, and view_card(..., "plots") in the Plots pane. To ask for the user name as the code runs, write user <- readline("GitHub user name: ") instead.

The card shows the repositories of the user, their stars and forks, the downloads of their release files and their GitHub Actions runs, with the runs per day, the most starred repositories and the languages. The page views and the clones are missing: GitHub shows them only to the owner of the repositories, which the next section explains.

What a user name brings

What collect_stats() reads depends on the token that it finds, a password that lets a program read from GitHub:

No token A token of yours The user’s own token
Repositories, stars, forks, languages, release downloads, GitHub Actions runs, followers yes yes yes
Contributions, commits, pull requests, issues and reviews yes yes
Page views, clones and visitors yes
When each star came yes
Requests that GitHub answers in an hour 60 5,000 5,000

Without a token, the statistics card and the GitHub Actions card are complete. A token of yours, for any user name, adds the contributions card and the activity card: GitHub gives the contributions only to requests with a token. The visitors card, the traffic on the statistics card and the chart of the stars on the code card need the user’s own token, since GitHub shows the traffic of a repository, and when each star came, only to its owner and collaborators.

rghcard asks GitHub about five times for each repository, so without a token, 60 requests an hour cover about a dozen repositories; the statistics of the repositories past them are left out. A token takes a minute to make and save, once, and the gh package finds it by itself after that. With it, the contributions card draws too:

view_card(contributions_card(stats, file = NULL))
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

For your own user name, your own token brings everything: collect_stats() without user reads the statistics of the owner of the token, and Draw the cards in R goes through it, with a history that keeps the traffic beyond the 14 days that GitHub keeps.

Every card of the user

One collection is enough for every card. In the Plots pane, its arrows go from one card to the next:

for (card in list(stats_card, contributions_card, activity_card,
                  actions_card, code_card)) {
  view_card(card(stats, file = NULL), "plots")
}

The visitors card is left out: it draws the traffic, which only the user’s own token reads. More cards explains each card.

A function of your own

A function of a few lines turns a user name into a card:

user_card <- function(user, card = stats_card, ...) {
  stats <- collect_stats(user = user, dir = NULL)
  view_card(card(stats, file = NULL, ...))
}

user_card("octocat")
user_card("octocat", contributions_card, theme = "light")

... passes the options of the card on, such as theme, panels and title. Each call reads GitHub again, so for several cards of one user, collect once, as in the section before.

An app: type a user name, see the card

A Shiny app takes the user name from a text box and draws the card in the page:

library(shiny)
library(rghcard)

ui <- fluidPage(
  tags$style("svg[role='img'] { max-width: 100%; height: auto; }"),
  textInput("user", "GitHub user name", "octocat"),
  actionButton("draw", "Draw the card"),
  uiOutput("card")
)

server <- function(input, output, session) {
  card <- eventReactive(input$draw, {
    stats <- collect_stats(user = input$user, dir = NULL)
    stats_card(stats, file = NULL)
  })
  output$card <- renderUI(HTML(card()))
}

shinyApp(ui, server)

Each click reads GitHub for the user, which takes a few seconds, longer for a user with many repositories; a user name that GitHub does not know shows an error instead of the card. On a server, everyone who uses the app shares its requests, so give the server a token: in the GITHUB_PAT environment variable, in the .Renviron file of the server, never in the code of the app, which others may read.

Save the card

A file name instead of NULL saves the card, and its end chooses the format:

stats_card(stats, "octocat-stats.svg")
stats_card(stats, "octocat-stats.png")

Draw the cards in R compares the formats, and Get started puts your own cards on your GitHub profile, where the rghcard action refreshes them.