Skip to content

Commit 113a0c9

Browse files
committed
create vignette
1 parent d4fd94a commit 113a0c9

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: "GitHub Repositories"
3+
format:
4+
html:
5+
theme: default
6+
---
7+
8+
9+
## Why
10+
11+
Within the National Stock Assessment Program (NSAP), it is a priority to place versioned code on GitHub Enterprise to facilitate ensuring that the code is automatically backed up without extra work from the individual user. This summary lists the number of repositories each user has under their personal GitHub account and how many of those are forks, which do not need to be on Enterprise.
12+
13+
```{r setup}
14+
#| echo: false
15+
#| warning: false
16+
17+
library(projectstats)
18+
library(dplyr)
19+
library(ggplot2)
20+
library(knitr)
21+
library(purrr)
22+
library(tidyr)
23+
24+
# All GitHub user names for people in NSAP
25+
user_names <- c(
26+
"Steven-Saul-NOAA",
27+
# Abby
28+
"AndreaChan-NOAA",
29+
"ClaireGonzales-NOAA",
30+
# Jeff
31+
# Len
32+
"kellijohnson-NOAA",
33+
"msupernaw",
34+
"Melissa-Karp",
35+
"ChristineStawitz-NOAA",
36+
"Andrea-Havron-NOAA",
37+
"Bai-Li-NOAA",
38+
"k-doering-NOAA",
39+
"PatrickLynch-NOAA",
40+
"e-perl-NOAA",
41+
"Schiano-NOAA",
42+
"sbreitbart-NOAA"
43+
)
44+
45+
projects <- data.frame(
46+
organization = c("NOAA-FIMS", "nmfs-ost", "nmfs-ost", "nmfs-ost"),
47+
repository = c("FIMS", "DisMAP", "asar", "ss3-source-code")
48+
)
49+
```
50+
51+
## Data
52+
53+
The following GitHub users names were searched: `r glue::glue_collapse({user_names}, sep = ", ", last = ", and ")`. For each username, we were able to determine the number of repositories that were held by the user and whether not not each repository represented original work or a fork of someone else's work.
54+
55+
```{r pull}
56+
# Pull the data from GitHub for each user name
57+
repository_data <- purrr::map_df(
58+
user_names,
59+
get_repositories,
60+
type = "users"
61+
)
62+
63+
# Get the number of stars for FIMS and dismap
64+
stars_data <- purrr::map2_df(
65+
.x = projects[, "organization"],
66+
.y = projects[, "repository"],
67+
.f = get_stargazers,
68+
.id = "project"
69+
) |>
70+
calculate_cumulative_stars()
71+
```
72+
73+
74+
## Results
75+
```{r results}
76+
#| tbl-cap: "Number of forked and original repositories held by each GitHub user name."
77+
#| echo: false
78+
79+
repository_data |>
80+
dplyr::mutate(fork = ifelse(fork, "forked", "original")) |>
81+
dplyr::group_by(login, fork) |>
82+
dplyr::count() |>
83+
tidyr::pivot_wider(names_from = "fork", values_from = "n") |>
84+
dplyr::arrange(dplyr::desc(original)) |>
85+
knitr::kable()
86+
```
87+
88+
```{r plots}
89+
#| fig-cap: "Number of stars since the first day a repository was starred."
90+
#| echo: false
91+
ggplot2::ggplot(
92+
stars_data,
93+
ggplot2::aes(day, cumulative_stars, color = project)
94+
) +
95+
ggplot2::geom_line() +
96+
ggplot2::xlab("Days since first star") +
97+
ggplot2::ylab("Number of stars")
98+
```

0 commit comments

Comments
 (0)