Skip to content

Instantly share code, notes, and snippets.

View dgkf's full-sized avatar

Doug Kelkhoff dgkf

View GitHub Profile
@dgkf
dgkf / cols.R
Last active September 12, 2025 18:26
dplyr at home
#' Column selector for `[` and `[[`
#'
#' @param ... Column names provided as `character` or `symbol` (could be
#' extended to allow other inputs!)
#' @return A `numeric` vector of column indices to select
#'
#' @examples
#' mtcars[cols(cyl, wt)] |> head()
#'
#' mtcars[cols(mpg:wt)] |> head()
@dgkf
dgkf / dgkf-R-CLA
Created December 30, 2022 14:56
Contributor License Agreement (dgkf/R)
# Contributor License Agreement (CLA)
By agreeing to this license agreement, you are agreeing to
permit @dgkf to relicense this project, which may include
your contributions of code, discussions, review or ideas,
without your approval.
# Why?
Licensing languages is tricky and I haven't researched which
@dgkf
dgkf / dataframes_exports.jl
Created January 25, 2020 23:37
Itemized DataFrames.jl exports
using DataFrames, CSV
df_exports = DataFrame(name = names(DataFrames))
# pull all objects from DataFrames namespace
df_exports[:,:obj] .= map(eachrow(df_exports)) do row
getfield(DataFrames, row.name)
end
# get object types
@dgkf
dgkf / decorator-infix.R
Created September 19, 2019 06:00
An attempt at creating a decorating operator in R
#' Right-associative operator for function decoration
#'
#' @description Decorating a function wraps the body of the inner function in a
#' decorator function, allowing for insertion of code before or after the body
#' of the inner function call.
#'
#' @param d the decorating function to wrap function \code{f}
#' @param f the function to decorate
#'
#' @return a new function call, functionally equivalent to the decorated