Daily Downloads

library(cranlogs)
library(echarts4r)

# My packages released on CRAN
packages <- c("r3dmol", "pagemap")

# Fetch data from CRAN
data <- cran_downloads(packages = packages, from = "2020-09-01")

# Total downloads
summary <- aggregate(data$count, by = list(Package = data$package), FUN = sum)

# Visualize
data %>%
  group_by(package) %>%
  e_chart(date) %>%
  e_line(
    serie = count,
    symbol = "circle",
    symbolSize = 1,
    smooth = TRUE,
    emphasis = list(focus = "series")
  ) %>%
  e_y_axis(name = "Downloads") %>%
  e_mark_line(
    data = list(
      type = "average",
      name = "AVG"
    ),
    symbolSize = 0
  ) %>%
  e_tooltip(trigger = "axis") %>%
  e_legend(top = "22%") %>%
  e_grid(bottom = "10%", right = "5%", top = "20%") %>%
  e_title(
    text = "Package Daily Download",
    subtext = paste(
      paste(summary$Package, summary$x, sep = ": "),
      collapse = ", "
    )
  )

Cumulative Downloads

data$cumulative <- ave(data$count, data$package, FUN = cumsum)

data %>%
  group_by(package) %>%
  e_chart(date) %>%
  e_line(
    serie = cumulative,
    symbol = "circle",
    symbolSize = 1,
    smooth = TRUE,
    emphasis = list(focus = "series")
  ) %>%
  e_tooltip(trigger = "axis") %>%
  e_legend(top = "22%") %>%
  e_grid(bottom = "10%", right = "5%", top = "20%") %>%
  e_title(
    text = "Package Cumulative Download",
    subtext = paste(
      paste(summary$Package, summary$x, sep = ": "),
      collapse = ", "
    )
  )