1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| library(shiny) library(argonR) library(argonDash) library(cranlogs) library(dplyr) library(jsonlite) library(magrittr) library(tibble) library(tidyr) library(billboarder) library(anytime) library(gh) library(purrr) library(shinycssloaders) source("sidebar.R") source("navbar.R") source("header.R") source("footer.R") source("cran_tabs.R") source("github_tabs.R") ui <- argonDashPage( title = "CRAN & GitHub Monitor", author = "czxa @ czxa.top", description = "A shiny app for monitoring downloads of my R packages and Stars on GitHub", sidebar = argonSidebar, navbar = argonNav, header = argonHeader, body = argonDashBody( argonTabItems( cran_tabs, github_tabs ) ), footer = argonFooter )
server = function(input, output) { crandf <- reactive({ cran_downloads( c("hwordcloud", "hpackedbubble", "hchinamap"), from = "2019-08-07", to = "last-day") %>% as_tibble() %>% group_by(package) %>% mutate(cumsum = cumsum(count)) }) output$cran_downloads <- renderBillboarder({ billboarder() %>% bb_linechart( data = crandf(), type = "line", mapping = bbaes(x = date, y = cumsum, group = package) ) %>% bb_x_axis(tick = list(format = "%Y-%m-%d", fit = FALSE)) %>% bb_x_grid(show = TRUE) %>% bb_y_grid(show = TRUE) %>% bb_color(palette = c("#5e72e4", "#2dce89", "#f5365c")) %>% bb_legend(position = "inset") %>% bb_labs(title = "My R Packages on CRAN", y = "Downloads", caption = "Data source: https://cran.r-project.org/") }) output$total_downloads <- renderText({ crandf() %>% ungroup() %>% summarise(total = sum(count)) %>% .[1,1] %>% as.character() }) output$last_month_downloads <- renderText({ cran_downloads(packages = c("hwordcloud", "hpackedbubble", "hchinamap"), when = "last-month") %>% summarise(sum(count)) %>% .[1,1] %>% as.character() }) output$last_week_downloads <- renderText({ cran_downloads(packages = c("hwordcloud", "hpackedbubble", "hchinamap"), when = "last-week") %>% summarise(sum(count)) %>% .[1,1] %>% as.character() }) USER <- "czxa" user <- gh("/users/:user", user=USER) repos <- gh("/users/:user/repos", user=USER, .limit = Inf) repos_df <- map_df(repos, ~.[c("name", "html_url", "stargazers_count", "forks_count", "updated_at", "pushed_at")]) %>% mutate(updated_at = anytime(pushed_at, asUTC=TRUE), pushed_at = NULL) %>% arrange(-stargazers_count) output$github_stars <- renderBillboarder({ billboarder() %>% bb_barchart(data = repos_df[1:10,], mapping = bbaes(x = name, y = stargazers_count)) %>% bb_color(palette = c("#5e72e4")) %>% bb_legend(show = F) %>% bb_x_grid(show = TRUE) %>% bb_y_grid(show = TRUE) %>% bb_labs(title = "Top 10 Repository on My GitHub @ czxa", y = "Stars", caption = "Data source: https://github.com/czxa") }) output$total_stars <- renderText({ repos_df %>% summarise(total = sum(stargazers_count)) %>% as.character() }) githubjson <- reactive({ read_json("https://api.github.com/users/czxa") }) output$followers <- renderText({ githubjson()$followers }) output$total_forks <- renderText({ repos_df %>% summarise(total = sum(forks_count)) %>% as.character() }) }
shinyApp(ui = ui, server = server)
|