Package 'codecountR'

Title: Counting Codes in a Text and Preparing Data for Analysis
Description: Data analysis often requires coding, especially when data are collected through interviews, observations, or questionnaires. As a result, code counting and data preparation are essential steps in the analysis process. Analysts may need to count the codes in a text (tokenization and counting of pre-established codes) and prepare the data (e.g., min-max normalization, Z-score, robust scaling, Box-Cox transformation, and non-parametric bootstrap). For the Box-Cox transformation (Box & Cox, 1964, <https://www.jstor.org/stable/2984418>), the optimal Lambda is determined using the log-likelihood method. Non-parametric bootstrap involves randomly sampling data with replacement. Two random number generators are also integrated: a Lehmer congruential generator for uniform distribution and a Box-Muller generator for normal distribution. Package for educational purposes.
Authors: Philippe Cohard [aut, cre]
Maintainer: Philippe Cohard <[email protected]>
License: GPL-3
Version: 0.0.4.5
Built: 2024-12-16 06:32:29 UTC
Source: CRAN

Help Index


analysCodesList

Description

analysCodesList

Usage

analysCodesList(dataS, codesLis)

Arguments

dataS

a character

codesLis

a character

Value

a list

Examples

codes=list("@essai@","@test@")
data = "this is an example @essai@, a bit long @essai@ text"
Result=analysCodesList(data,codes)
Result

bootStrap

Description

bootStrap

Usage

bootStrap(nameDframe, grpSize)

Arguments

nameDframe

a data.frame

grpSize

a number

Value

a matrix

Examples

j=c(10,14,56,30,58,78,99,1)
k=c(10,12,14,16,18,20,22,24)
x=data.frame(j,k)
res=bootStrap(x,5)
res

BoxAndCox

Description

BoxAndCox

Usage

BoxAndCox(rawVect, minLambda)

Arguments

rawVect

a vector

minLambda

a number

Value

a list

Examples

vec=rlnorm(100, log(3), log(3))
BandC=BoxAndCox(vec, -3)
BandC
BAC=unlist(BandC$par)
BAC
rawVectBCFinal=unlist(subCalcBoxAndCox(vec, BandC$par))

BoxMullerGen

Description

BoxMullerGen

Usage

BoxMullerGen(r, s)

Arguments

r

a number

s

a number

Value

a vector

Examples

#with runif
v=BoxMullerGen(runif(1), runif(1))
print(v)

#with congruGen
seed = 123456789
X=c()
for(i in 1: 2) {
Z=congruGen(seed)
seed=Z$seedUpdate
X=append(X, Z$aleaNum)
}
#print(X)

N=BoxMullerGen(X[1], X[2])
print(N[1])
print(N[2])

codeCount

Description

codeCount

Usage

codeCount(dataSet, code)

Arguments

dataSet

a character

code

a character

Value

a number

Examples

data = "this is an example @essai@"
codeCount(data, "@essai@") #number of lines containing the chain

congruGen

Description

congruGen

Usage

congruGen(seed, a)

Arguments

seed

a number

a

a number

Value

a list

Examples

seed = 123456789
for(i in 1: 10) {
Z=congruGen(seed)
seed=Z$seedUpdate
num=Z$aleaNum
print(num)
}

loadCodes

Description

loadCodes

Usage

loadCodes(txtFile)

Arguments

txtFile

a character

Value

a list

Examples

theFile =system.file("codesList.txt", package = "codecountR")
data=loadCodes(theFile)

normMinMax

Description

normMinMax

Usage

normMinMax(nameDframe)

Arguments

nameDframe

a data.frame

Value

a data.frame

Examples

j=c(10,14,56,30,58,78,99,1)
k=c(10,12,14,16,18,20,22,24)
x=data.frame(j,k)
xMinMax=normMinMax(x)
xMinMax

robustScal

Description

robustScal

Usage

robustScal(nameDframe)

Arguments

nameDframe

a data.frame

Value

a data.frame

Examples

j=c(10,14,56,30,58,78,99,1)
k=c(10,12,14,16,18,20,22,24)
x=data.frame(j,k)
xRsc=robustScal(x)
xRsc

subCalcBoxAndCox

Description

subCalcBoxAndCox

Usage

subCalcBoxAndCox(sortedVect, actualLambda)

Arguments

sortedVect

a vector

actualLambda

a number

Value

a vector

Examples

vec=rlnorm(100, log(3), log(3))
BandC=subCalcBoxAndCox(vec, -3)

tokenization

Description

tokenization

Usage

tokenization(txtFile)

Arguments

txtFile

a character

Value

a list

Examples

theFile =system.file("ExText.txt", package = "codecountR")
data=tokenization(theFile)

zScore

Description

zScore

Usage

zScore(nameDframe)

Arguments

nameDframe

a data.frame

Value

a data.frame

Examples

j=c(10,14,56,30,58,78,99,1)
k=c(10,12,14,16,18,20,22,24)
x=data.frame(j,k)
xZsc=zScore(x)
xZsc