Skip to content

Instantly share code, notes, and snippets.

View yannikbuhl's full-sized avatar
💭
Typing ...

Yannik Buhl yannikbuhl

💭
Typing ...
View GitHub Profile
@yannikbuhl
yannikbuhl / get_month_from_isoweek.R
Last active February 28, 2022 14:19
Get month to which a calendar week belongs (calculated by mode)
#' 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 December 7, 2020 13:44
Plotting cumulative or daily downloads of your R package on CRAN
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) {