Created
March 14, 2025 10:14
-
-
Save seandavi/a8a9747688c0bce88a122f8155ddd687 to your computer and use it in GitHub Desktop.
Create a simple html page of github repositories based on "topic"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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