knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

dacol

CRAN status R build status Codecov test coverage Lifecycle: experimental

dacol provides utilities to add or modify columns in dataframe.

The utilities include:

More info: https://ldanai.github.io/dacol/

Installation

You can install dacol from github with:

# install.packages("remotes")
remotes::install_github("ldanai/dacol")

Example

This shows how to use dacol:

library(dacol)
library(dplyr)

max = 30
df = tibble(x1 = seq(-1.2*max, 1.2*max, length.out = 200),
            x2 = seq(0, max, length.out = 200),
            x3 = sample(200))

df

df = 
  df %>% 
  mutate(
    # Transformation
    y_cosine   = dc_cosine(x1, max),
    y_logistic = dc_logistic(x2, max),
    y_zcore    = dc_zscore(x2),

    # Distant between 2 vector columns
    y_dist_canb = dc_dist_canberra(x2, x3),
    y_dist_cos  = dc_dist_cosine(x2, y_zcore),
    y_dist_euc  = dc_dist_euclidean(x2, y_zcore),
    y_dist_pear = dc_dist_pearson(x2, y_zcore),

    # Manage outliers
    y_trim = dc_trim_outlier(x3, 0.01),
    y_norm = dc_normalize_ptile(x3, 0.01),

    # Stats measures
    y_mode = dc_mode(x3),
    y_ceil = dc_ceiling(x1, -1),

    # Band segmentation
    y_dec_band1  = dc_decile_band(x3),
    y_dec_band2  = dc_decile_band(x3, c(seq(0, 0.9, 0.1))),
    y_dec_ptile1 = dc_decile_ptile(x3),
    y_dec_ptile2 = dc_decile_ptile(x3, c(seq(0, 0.9, 0.1))),

    # Rank percentile
    y_ranked1 = dc_rank_ptile(x3), 
    y_ranked2 = dc_rank_ptile(x3, c(seq(1, 100, 1))) 
  )

df

Please note that the 'dacol' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



ldanai/dacol documentation built on May 15, 2020, 5:05 p.m.