Skip to content

Commit

Permalink
Clean remaining files
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed May 2, 2024
1 parent 164241c commit 2bde353
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 145 deletions.
8 changes: 5 additions & 3 deletions R/plot_commits_github.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,17 @@
#' pkgmeta::plot_commits_github(repos_commits)
#' }
#'
plot_commits_github <- function(repos_commits) {
plot_commits_github <- function(repos_commits)
{
n_commits <- repos_commits %>%
dplyr::count(.data$author_login) %>%
dplyr::rename(n_commits = .data$n)

repos_commits %>%
dplyr::left_join(n_commits, by = "author_login") %>%
dplyr::mutate(user = sprintf("%s (n = %d)", .data$author_login, .data$n_commits)) %>%
dplyr::mutate(
user = sprintf("%s (n = %d)", .data$author_login, .data$n_commits)
) %>%
ggplot2::ggplot(ggplot2::aes(
x = as.Date(.data$datetime) ,
y = forcats::fct_reorder(.data$repo, .data$datetime),
Expand All @@ -39,5 +42,4 @@ plot_commits_github <- function(repos_commits) {
y = "Repo",
x = "Date"
)

}
112 changes: 69 additions & 43 deletions R/plot_r_releases.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,53 @@
#' @examples
#' releases <- get_r_releases()
#' head(releases)
get_r_releases <- function(releases = rversions::r_versions(dots = TRUE)) {
get_r_releases <- function(releases = rversions::r_versions(dots = TRUE))
{
releases %>%
tidyr::separate(col = "version",
into = c("major", "minor", "patch"),
sep = "\\.",
remove = FALSE) %>%
dplyr::mutate(patch = dplyr::if_else(is.na(.data$patch), 0L, as.integer(.data$patch)),
major = as.integer(.data$major),
minor = as.integer(.data$minor),
diff.major = .data$major - dplyr::lag(.data$major, n = 1L),
diff.minor = .data$minor - dplyr::lag(.data$minor, n = 1L),
diff.patch = .data$patch - dplyr::lag(.data$patch, n = 1L),
release_type = dplyr::if_else(.data$diff.major > 0,
"Major",
dplyr::if_else(.data$diff.minor > 0,
"Minor",
dplyr::if_else(.data$diff.patch > 0,
"Patch",
"Initial")))) %>%
dplyr::mutate(release_type = dplyr::if_else(is.na(.data$release_type),
"Initial",
.data$release_type),
label = sprintf("v%s (%s): %s",
.data$version,
.data$date,
.data$release_type))

tidyr::separate(
col = "version",
into = c("major", "minor", "patch"),
sep = "\\.",
remove = FALSE
) %>%
dplyr::mutate(
patch = dplyr::if_else(
is.na(.data$patch),
0L,
as.integer(.data$patch)
),
major = as.integer(.data$major),
minor = as.integer(.data$minor),
diff.major = .data$major - dplyr::lag(.data$major, n = 1L),
diff.minor = .data$minor - dplyr::lag(.data$minor, n = 1L),
diff.patch = .data$patch - dplyr::lag(.data$patch, n = 1L),
release_type = dplyr::if_else(
.data$diff.major > 0,
"Major",
dplyr::if_else(
.data$diff.minor > 0,
"Minor",
dplyr::if_else(
.data$diff.patch > 0,
"Patch",
"Initial"
)
)
)
) %>%
dplyr::mutate(
release_type = dplyr::if_else(
is.na(.data$release_type),
"Initial",
.data$release_type
),
label = sprintf(
"v%s (%s): %s",
.data$version,
.data$date,
.data$release_type
)
)
}

#' Plot R Releases
Expand All @@ -50,22 +70,28 @@ get_r_releases <- function(releases = rversions::r_versions(dots = TRUE)) {
#' \dontrun{
#' plot_r_releases()
#' }
plot_r_releases <- function(r_releases = get_r_releases(),
title = "R Releases") {

g <- r_releases %>%
ggplot2::ggplot(ggplot2::aes_string(x = "date",
y = "major",
col = "release_type",
label = "label")) +
ggplot2::geom_point(ggplot2::aes(alpha = 0.5)) +
ggplot2::theme_bw() +
ggplot2::scale_y_discrete() +
ggplot2::labs(title = title,
x = "Date",
y = "Major Release Version",
color = "Type",
alpha = "")
plot_r_releases <- function(
r_releases = get_r_releases(),
title = "R Releases"
)
{
g <- r_releases %>%
ggplot2::ggplot(ggplot2::aes_string(
x = "date",
y = "major",
col = "release_type",
label = "label"
)) +
ggplot2::geom_point(ggplot2::aes(alpha = 0.5)) +
ggplot2::theme_bw() +
ggplot2::scale_y_discrete() +
ggplot2::labs(
title = title,
x = "Date",
y = "Major Release Version",
color = "Type",
alpha = ""
)

plotly::ggplotly(g, tooltip = "label")
plotly::ggplotly(g, tooltip = "label")
}
32 changes: 21 additions & 11 deletions R/plot_rpackages.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
#' pkgs <- get_github_packages()
#' plot_github_pkgs_over_time(pkgs)}
#'
plot_github_pkgs_over_time <- function(df_pkgs,
last_update = Sys.time()) {
fakin_date_start <- lubridate::as_datetime("2017-05-01")
plot_github_pkgs_over_time <- function(
df_pkgs,
last_update = Sys.time()
)
{
as_date <- lubridate::as_datetime

fakin_date_start <- as_date("2017-05-01")

df_pkgs %>%
dplyr::mutate(
created_at = lubridate::as_datetime(.data$created_at),
pushed_at = lubridate::as_datetime(.data$pushed_at)
created_at = as_date(.data$created_at),
pushed_at = as_date(.data$pushed_at)
) %>%
ggplot2::ggplot(ggplot2::aes(
x = .data$created_at,
Expand All @@ -33,19 +38,24 @@ plot_github_pkgs_over_time <- function(df_pkgs,
xintercept = fakin_date_start,
size = 2, alpha = 0.5, col = "grey"
) +
ggplot2::geom_segment(ggplot2::aes(yend = .data$name, xend = .data$pushed_at),
ggplot2::geom_segment(
ggplot2::aes(yend = .data$name, xend = .data$pushed_at),
size = 1.3,
arrow = ggplot2::arrow(length = ggplot2::unit(0.1, "inches"))
arrow = ggplot2::arrow(length = ggplot2::unit(0.1, "inches")
)
) +
ggplot2::theme_bw() +
ggplot2::labs(
title = "Temporal development of KWB-R packages on Github",
subtitle = glue::glue("Last update: {last_update}"),
y = "Repository Name",
x = "Date",
caption = glue::glue("Start of the arrow is the first release on Github, while the end of the arrow
represents the lasted 'push' activity to the repository. The vertical grey line
stands for the start date ({fakin_date_start}) of the FAKIN project at KWB which
serves as a booster of this publishing process (last update: {last_update}")
caption = glue::glue(paste0(
"Start of the arrow is the first release on Github, while the end of ",
"the arrow represents the lasted 'push' activity to the repository. ",
"The vertical grey line stands for the start date ",
"({fakin_date_start}) of the FAKIN project at KWB which serves as a ",
"booster of this publishing process (last update: {last_update})"
))
)
}
7 changes: 5 additions & 2 deletions R/plot_rpackages_releases.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
#' plot_github_pkgs_releases(pkgs_releases)
#' }
#'
plot_github_pkgs_releases <- function(pkgs_releases,
last_update = Sys.time()) {
plot_github_pkgs_releases <- function(
pkgs_releases,
last_update = Sys.time()
)
{
# fakin_date_start <- lubridate::as_date("2017-05-01")

pkgs_releases %>%
Expand Down
21 changes: 10 additions & 11 deletions R/travis_pkg_install_script.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#' Travis Package Install Script
#'
#' @description Needs to be Run before rendering vignettes
#' @param pkgs dataframe with R packages as retrieved by
#' get_github_packages()
#' @return installs kwb-r packages
#' @export
travis_pkg_install_script <- function(pkgs = pkgmeta::get_github_packages()) {
sapply(
pkgs$full_name,
FUN = function(pkg) {
try(remotes::install_github(
repo = pkg,
dependencies = TRUE,
upgrade = "always"
))
}
)
travis_pkg_install_script <- function(pkgs = pkgmeta::get_github_packages())
{
sapply(pkgs$full_name, function(pkg) {
try(remotes::install_github(
repo = pkg,
dependencies = TRUE,
upgrade = "always"
))
})
}
Loading

0 comments on commit 2bde353

Please sign in to comment.