The cards show a few numbers and charts out of the statistics that
collect_stats() collects, and the statistics hold much
more: the page views of each repository on each day, the sites that sent
the visitors, each star with its time, each GitHub Actions run, and your
contributions on each day since you joined GitHub. This article looks
into them with base R. It uses the statistics of the made-up user of
get_example_stats(); yours come from
collect_stats(), or from read_stats() once
collected, as Plot the
cards in R shows.
library(rghcard)
stats <- get_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 (100 rows), profile (1 row), contributions (2822 rows), commits (69 rows), contribution_types (8 rows)
#> Each table is a data frame, such as stats$views: ?rghcard_stats describes their columns.A list of 14 tables
The statistics are a list of data frames, one for each table of the
history, and $ gets one, such as stats$repos.
In RStudio or Positron, View(stats$repos) shows a table
whole.
names(stats)
#> [1] "repos" "views" "clones" "traffic" "referrers" "pages" "releases" "actions" "languages"
#> [10] "stars" "profile" "contributions" "commits" "contribution_types"| Table | One row is |
|---|---|
repos |
a repository, on a day of collection |
views |
the page views of a repository on a day |
clones |
the clones of a repository on a day |
traffic |
GitHub’s totals of a repository for the 14 days it keeps, on a day of collection |
referrers |
a site that sent visitors to a repository in those 14 days |
pages |
one of the most viewed pages of a repository in those 14 days |
releases |
a file of a release, with its downloads |
actions |
a GitHub Actions run |
languages |
the code of a repository in a language |
stars |
the stars of a repository on a day |
profile |
the followers of the user, on a day of collection |
contributions |
the contributions of the user on a day |
commits |
the commits of the user in a repository in a year |
contribution_types |
the contributions of the user in a year, by type |
?rghcard_stats describes every column of every table.
Days and times are text, such as "2026-12-03", in UTC, and
as.Date() turns them into dates. Three attributes say whose
the statistics are and when they were collected:
Your repositories
repos has a row for each repository on each day of
collection, so the repositories as they are now are the rows of the last
day:
repos <- stats$repos[stats$repos$date == max(stats$repos$date), ]
repos <- repos[order(repos$stars, decreasing = TRUE), ]
repos[, c("repo", "stars", "forks", "watchers", "open_issues", "language")]
#> repo stars forks watchers open_issues language
#> 1 tidysurvey 48 9 6 5 R
#> 2 plotkit 23 4 4 2 R
#> 3 shiny-weather 12 2 2 1 R
#> 5 workshop-2026 7 3 2 0 R
#> 8 pyscripts 5 1 1 1 Python
#> 4 thesis 3 0 1 0 TeX
#> 6 website 2 0 1 0 HTML
#> 7 dotfiles 1 0 1 0 ShellThe ten with the most stars, as bars. The first par()
sets quieter axes, gray and without a box, which stay for the other
charts of this article, and the second leaves room on the left for the
longest name:
top <- head(repos, 10)
par(las = 1, bty = "n", fg = "#c2c2c2", col.axis = "#666666")
par(mar = c(2.5, max(nchar(top$repo)) / 2 + 1, 2, 1))
barplot(rev(top$stars), names.arg = rev(top$repo), horiz = TRUE, space = 0.5,
col = "#257de0", border = NA, main = "Stars per repository")
Page views and clones
views and clones have a row for each
repository and day. Their sum per day, without the day of the
collection, which GitHub was still counting and would look like a
drop:
views <- aggregate(count ~ date, data = stats$views, FUN = sum)
views <- views[as.Date(views$date) < attr(stats, "updated"), ]
head(views)
#> date count
#> 1 2026-11-03 47
#> 2 2026-11-04 30
#> 3 2026-11-05 26
#> 4 2026-11-06 53
#> 5 2026-11-07 22
#> 6 2026-11-08 9
par(mar = c(2.5, 3, 2, 1))
barplot(views$count, names.arg = format(as.Date(views$date), "%d %b"),
col = "#257de0", border = NA, main = "Page views per day")
Their sum per repository:
per_repo <- aggregate(cbind(count, uniques) ~ repo, data = stats$views, FUN = sum)
per_repo[order(per_repo$count, decreasing = TRUE), ]
#> repo count uniques
#> 6 tidysurvey 434 239
#> 2 plotkit 202 99
#> 4 shiny-weather 143 70
#> 7 website 114 65
#> 8 workshop-2026 88 49
#> 3 pyscripts 52 31
#> 5 thesis 34 21
#> 1 dotfiles 5 4uniques counts someone who visits on three days three
times, once a day. traffic has GitHub’s own totals for the
14 days it keeps, in which they count once: visitors and
cloners.
stats$traffic[, c("repo", "views", "visitors", "clones", "cloners")]
#> repo views visitors clones cloners
#> 1 tidysurvey 238 79 272 77
#> 2 plotkit 89 27 105 33
#> 3 shiny-weather 72 20 103 28
#> 4 thesis 24 8 11 5
#> 5 workshop-2026 37 12 27 8
#> 6 website 61 20 93 29
#> 7 dotfiles 3 1 9 4
#> 8 pyscripts 30 9 14 6Where the visitors come from
referrers has the ten sites that sent the most visitors
to each repository in the 14 days that GitHub keeps, on each day of
collection. The sites of the last collection, summed over the
repositories, and the ten that sent the most as bars:
latest <- stats$referrers[stats$referrers$fetched == max(stats$referrers$fetched), ]
sites <- aggregate(count ~ referrer, data = latest, FUN = sum)
sites <- sites[order(sites$count, decreasing = TRUE), ]
sites
#> referrer count
#> 5 google.com 103
#> 4 github.com 67
#> 2 example-user.r-universe.dev 22
#> 6 stackoverflow.com 9
#> 3 fosstodon.org 6
#> 1 duckduckgo.com 5
top <- head(sites, 10)
par(mar = c(2.5, max(nchar(top$referrer)) / 2 + 1, 2, 1))
barplot(rev(top$count), names.arg = rev(top$referrer), horiz = TRUE, space = 0.5,
col = "#257de0", border = NA, main = "Page views per referring site")
pages has the most viewed pages of each repository in
the same way:
pages <- stats$pages[stats$pages$fetched == max(stats$pages$fetched), ]
pages[order(pages$count, decreasing = TRUE), c("title", "count", "uniques")]
#> title count uniques
#> 1 GitHub · example-user/tidysurvey 98 40
#> 5 GitHub · example-user/plotkit 52 21
#> 7 GitHub · example-user/shiny-weather 33 15
#> 2 Issues · example-user/tidysurvey 24 8
#> 8 GitHub · example-user/website 18 8
#> 9 GitHub · example-user/workshop-2026 16 9
#> 3 README.md · example-user/tidysurvey 15 9
#> 4 Releases · example-user/tidysurvey 12 7
#> 6 R · example-user/plotkit 9 4Contributions
contributions has a row for each day since the user
joined GitHub. Their sum per year, of which the first and the last are
not whole years:
contributions <- stats$contributions
per_year <- tapply(contributions$count, substr(contributions$date, 1, 4), sum)
per_year
#> 2019 2020 2021 2022 2023 2024 2025 2026
#> 33 105 214 420 477 685 1028 1170
par(mar = c(2.5, 3.5, 2, 1))
barplot(per_year, space = 1, col = "#257de0", border = NA, main = "Contributions per year")
Per day of the week, from 1 for Monday to 7 for Sunday, which
format() gives in any language:
weekday <- as.integer(format(as.Date(contributions$date), "%u"))
per_weekday <- tapply(contributions$count, weekday, sum)
names(per_weekday) <- c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
per_weekday
#> Mon Tue Wed Thu Fri Sat Sun
#> 713 658 710 695 728 309 319
barplot(per_weekday, space = 1, col = "#257de0", border = NA,
main = "Contributions per day of the week")
contribution_types splits each year by type.
private counts the contributions to private repositories,
which GitHub gives as bare numbers:
stats$contribution_types
#> year commits issues pull_requests reviews repositories private
#> 1 2019 20 5 2 0 3 3
#> 2 2020 63 13 12 14 2 1
#> 3 2021 128 24 35 15 2 10
#> 4 2022 252 46 66 33 1 22
#> 5 2023 286 61 71 38 2 19
#> 6 2024 411 72 110 64 1 27
#> 7 2025 617 121 176 81 2 31
#> 8 2026 702 132 182 111 1 42Code and commits
languages has the bytes of code of each repository in
each language, as the language bar of a repository counts them. Their
sum per language, in kilobytes, and the ten largest as bars:
code <- aggregate(bytes ~ language, data = stats$languages, FUN = sum)
code$kilobytes <- round(code$bytes / 1000)
code <- code[order(code$bytes, decreasing = TRUE), ]
code
#> language bytes kilobytes
#> 6 R 748368 748
#> 9 TeX 243980 244
#> 3 HTML 61210 61
#> 5 Python 42167 42
#> 1 C++ 38212 38
#> 4 JavaScript 17557 18
#> 8 Shell 9120 9
#> 7 SCSS 8344 8
#> 2 CSS 4120 4
#> 10 Vim Script 3080 3
top <- head(code, 10)
par(mar = c(2.5, max(nchar(top$language)) / 2 + 1, 2, 1))
barplot(rev(top$kilobytes), names.arg = rev(top$language), horiz = TRUE, space = 0.5,
col = "#257de0", border = NA, main = "Code per language, in kilobytes")
commits has the commits of the user in each repository
each year, in repositories of anyone: owner says whose.
Their sum per repository:
commits <- aggregate(commits ~ owner + repo, data = stats$commits, FUN = sum)
commits[order(commits$commits, decreasing = TRUE), ]
#> owner repo commits
#> 7 example-user tidysurvey 783
#> 3 example-user plotkit 455
#> 5 example-user shiny-weather 270
#> 4 example-user pyscripts 267
#> 8 example-user website 205
#> 9 example-user workshop-2026 166
#> 6 example-user thesis 155
#> 2 rstats-group ggextra 107
#> 1 example-user dotfiles 71Stars over time
stars has the stars of each repository on each day it
got any, since the repository was created, so they can be counted up to
any day. Their number over time, of all the repositories together:
per_day <- aggregate(count ~ date, data = stats$stars, FUN = sum)
par(mar = c(2.5, 3.5, 2, 1))
plot(as.Date(per_day$date), cumsum(per_day$count), type = "s", lwd = 2, col = "#257de0",
xlab = "", ylab = "", main = "Stars over time")
GitHub Actions runs
actions has a row for each run, with how it ended and
its times. The runs of each workflow, by how they ended:
runs <- stats$actions
table(runs$workflow, runs$conclusion)
#>
#> failure success
#> Deploy app 2 5
#> pages build and deployment 1 18
#> R-CMD-check 6 55The minutes that a run of each workflow takes, from its start to its end, as a median:
utc <- function(x) as.POSIXct(x, tz = "UTC", format = "%Y-%m-%dT%H:%M:%SZ")
runs$minutes <- as.numeric(difftime(utc(runs$finished), utc(runs$started), units = "mins"))
aggregate(minutes ~ workflow, data = runs, FUN = median)
#> workflow minutes
#> 1 Deploy app 3.433333
#> 2 pages build and deployment 1.033333
#> 3 R-CMD-check 9.066667Releases and followers
releases has the downloads of each file of each release,
since it was published:
releases <- stats$releases[stats$releases$fetched == max(stats$releases$fetched), ]
releases[, c("repo", "release", "file", "downloads")]
#> repo release file downloads
#> 1 tidysurvey v1.2.0 tidysurvey_1.2.0.tar.gz 312
#> 2 tidysurvey v1.1.0 tidysurvey_1.1.0.tar.gz 188
#> 3 plotkit v0.3.0 plotkit_0.3.0.tar.gz 85
#> 4 shiny-weather v1.0.0 shiny-weather.zip 14profile has the followers of the user on each day of
collection, so with weekly collections it shows how they grow:
stats$profile
#> date followers following
#> 1 2026-12-03 87 41Keep what you find
The tables are already CSV files, in the folder of the history. A table of your own saves as one too, for a spreadsheet:
write.csv(sites, "referrers.csv", row.names = FALSE)ggplot2, or any other package of charts, draws the tables as well as base R does.