Skip to content

Instantly share code, notes, and snippets.

Avatar

Yannik Buhl yannikbuhl

View GitHub Profile
@yannikbuhl
yannikbuhl / get_month_from_isoweek.R
Last active Feb 28, 2022
Get month to which a calendar week belongs (calculated by mode)
View get_month_from_isoweek.R
#' Get the month (or all days) of a calendar week
#'
#' @param week Atomic character vector. Specify the calendar week you want \cr
#' to have parsed. Must be of format 'YYYY-WW' (e.g., '2020-03').
#' @param .df Logical. Defaults to FALSE. If TRUE, the function does not \cr
#' return a single integer vector with the month information but a \cr
#' data.frame with all days and dates of the chosen calendar week, including \cr
#' information on which month each day belongs to.
#'
#' @return Atomic integer vector containing the month to which the calendar week \cr
@yannikbuhl
yannikbuhl / cranlogs.R
Last active Dec 7, 2020
Plotting cumulative or daily downloads of your R package on CRAN
View cranlogs.R
library(cranlogs)
library(ggplot2)
cran <- function(package, cumulative = FALSE, from = "2019-01-01") {
# Get downloads
mls <- cran_downloads(packages = package, from = from, to = Sys.Date() - 1)
if (cumulative == FALSE) {