R/RcppExports.R

Defines functions ass mode qgramdist

Documented in ass mode qgramdist

# This file was generated by Rcpp::compileAttributes
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @title ass
#' @description for some given integer n generates all possible 0-1 assignment
#' vectors of 2n survey participants in such a way that exactly n of them are assigned to group 0 (control)
#' and the other n ones are assigned to group 1 (treatment).
#' 
#' @param n an integer, a number of positive responses,
#' @return a matrix with 2n columns and an appropriate
#' number of rows
#' 
#' @export
ass <- function(n) {
    .Call('hw6_ass', PACKAGE = 'hw6', n)
}

#' @title mode
#' @description Calculates a mode number, which is the most frequently occuring number in a given vector. 
#' If the mode is ambigous returns a smaller number of equal mode.
#' 
#' @param x a vector of integers
#' @return an integer value - mode
#' 
#' @export
mode <- function(x) {
    .Call('hw6_mode', PACKAGE = 'hw6', x)
}

#' @title qgramdist
#' @description Calculates a q-gram distance \url{https://journal.r-project.org/archive/2014-1/loo.pdf} 
#' between two vectors of integers.
#' 
#' @param x a vector of single (<10 if q>1) integers
#' @param y a vector of single (<10 if q>1) integers
#' @param q an integer, q in q-gram distance
#' @return an integer value - q-gram distance, Inf if q is larger then a vector's length
#' 
#' @export
qgramdist <- function(x, y, q) {
    .Call('hw6_qgramdist', PACKAGE = 'hw6', x, y, q)
}
lidiaad/hw6 documentation built on May 21, 2019, 6:13 a.m.