Skip to content

Instantly share code, notes, and snippets.

@seandavi
Created March 14, 2025 10:14
Show Gist options
  • Save seandavi/a8a9747688c0bce88a122f8155ddd687 to your computer and use it in GitHub Desktop.
Save seandavi/a8a9747688c0bce88a122f8155ddd687 to your computer and use it in GitHub Desktop.
Create a simple html page of github repositories based on "topic"
---
title: "Github Repos for Topic"
author: "Sean Davis"
format: html
params:
gh_topic: "r01ca230551"
---
## Required packages
```{r}
library(gh)
library(DT)
```
## Repositories
```{r}
repos <- gh("/search/repositories?q=topic:{topic}", topic = params$gh_topic)
repos_df <- lapply(repos$items, function(repo) {
data.frame(
name = repo$name,
full_name = repo$full_name,
description = ifelse(is.null(repo$description), NA, repo$description),
html_url = repo$html_url,
stars = repo$stargazers_count,
forks = repo$forks_count,
language = ifelse(is.null(repo$language), NA, repo$language),
created_at = repo$created_at,
updated_at = repo$updated_at,
stringsAsFactors = FALSE
)
}) |> dplyr::bind_rows()
```
```{r}
repos_df |> dplyr::select(name, full_name, html_url, description, stars, language) |>
dplyr::arrange(dplyr::desc(stars)) |>
DT::datatable(rownames = FALSE,
options = list(pageLength = 50))
```
## Repository dataframe details
```{r}
dplyr::glimpse(repos_df)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment