README.md

TrackerDashboard

Credit belongs to Hadley Wickham, the creator of the original CRAN package download shiny application. This is my own version of his project using the bs4Dash package and including Python data.

Google BigQuery

The download logs from PyPI in the dashboard requires the use of BigQuery, which is accomplished in R through the use of the bigrquery package. BigQuery has a free tier, which offers 10 GB storage and up to 1 TB queries per month. For working with Google APIs, refer to the gargle package, which bigrquery uses to deal with authentication, and its vignettes.

BigQuery Setup

In order to use BigQuery:

  1. Set up a Google Cloud account here and create a new project.

  2. Enable API for Google Cloud platform (GCP) as specified in the gargle documentation under the section Enable API(s).

  3. Set up billing for Google Cloud account (see documentation). No payment is required if usage stays under free tier.

  4. Create service account and create key (.json file).

  5. Set environment variable:

# Name of the project created
Sys.setenv(BIGQUERY_TEST_PROJECT = "project_name")
# Service account key
Sys.setenv(path_to_bq_token = "path_to_key_json.json")
# For non-interactive use 
bq_auth(path = Sys.getenv("path_to_bq_token"))
  1. For non-interactive use, see the gargle documentation.

Installation

Install TrackerDashboard from GitHub with:

# install.packages("devtools")
devtools::install_github("YangWu1227/tracker-dashboard")

Application

To run app.R:

library(TrackerDashboard)

# Service account token ---------------------------------------------------

bq_auth(path = Sys.getenv("path_to_bq_token"))

# Pool object -------------------------------------------------------------

pool <- dbPool(
  drv = bigquery(),
  project = "bigquery-public-data",
  dataset = "pypi",
  billing = bq_test_project()
)
onStop(function() {
  poolClose(pool)
})

# Variables for default R text inputs -------------------------------------

top5 <- cran_top_downloads(count = 5)$package
today <- Sys.Date() - 1
last_month <- today - 60

runApp(top5, today, last_month, pool)

Dashboard Interface

Polars (Python)

Data.Table & Dplyr (R)



YangWu1227/tracker_dashboard documentation built on June 29, 2024, 5:09 p.m.