Learn R Programming

acss (version 0.1-1)

normalize_string: Helper functions for calculating cognitive complexity.

Description

normalize_string takes a character vector and normalizes its input using the symbols 0, 1, 2...9. count_class takes a character vector and an integer n (with the restriction that the number of different symbols in the character vector doesn't exceed n) and returns the total number of strings that are equivalent to the input when normalized and considering n. alternations returns the number of alternations of symbols in a string.

Usage

normalize_string(string)

count_class(string, n)

alternations(string, proportion = FALSE)

Arguments

string
character vector containing the to be analyzed strings (can contain multiple strings).
n
numeric, the number of possible symbols (not necessarily actually appearing in str).
proportion
boolean, indicating if the result from alternation should be given as a proportion (between 0 and 1) or the raw number of alternations (default is FALSE correpsonding to raw values).

Value

  • [object Object],[object Object],[object Object]

Details

nothing yet.

Examples

Run this code
#normalize_string:
normalize_string(c("HUHHEGGTE", "EGGHHU"))

normalize_string("293948837163536")

# count_class
count_class("010011",2)

count_class("332120",4)

count_class(c("HUHHEGGTE", "EGGHHU"), 5)
count_class(c("HUHHEGGTE", "EGGHHU"), 6)

# alternations:
alternations("0010233")
alternations("0010233", proportion = TRUE)

alternations(c("HUHHEGGTE", "EGGHHU"))
alternations(c("HUHHEGGTE", "EGGHHU"), proportion = TRUE)

Run the code above in your browser using DataLab