From ec023d9de339fe11800408f4350303095e95f1fa Mon Sep 17 00:00:00 2001 From: sdgamboa Date: Wed, 3 Apr 2024 17:14:32 -0400 Subject: [PATCH] Add freq2SCores2 function. --- NAMESPACE | 1 + R/utils.R | 24 ++++++++++++++++++++++++ man/freq2Scores2.Rd | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 man/freq2Scores2.Rd diff --git a/NAMESPACE b/NAMESPACE index 81d0e57..d1be678 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -8,6 +8,7 @@ export(filterData) export(filterDataDiscrete) export(filterDataNumeric) export(freq2Scores) +export(freq2Scores2) export(getDataReady) export(getNsti) export(getSetWithIDs) diff --git a/R/utils.R b/R/utils.R index 897e7ec..5fb1270 100644 --- a/R/utils.R +++ b/R/utils.R @@ -20,6 +20,30 @@ freq2Scores <- function(x) { ) } +#' Frequency to scores 2 +#' +#' \code{freq2Scores} converts the keywords in the "Frequency" +#' column of a bugphyzz dataset into numeric scores, which are interpreted +#' as probabilities. This v2 should be used after performing ASR in +#' numeric attributes. +#' +#' @param x A character vector. +#' +#' @return A numeric vector. +#' +#' @export +#' +freq2Scores2 <- function(x) { + x <- tolower(x) + dplyr::case_when( + x == 'always' ~ 1, + x == 'usually' ~ 0.9, + x == 'sometimes' ~ 0.5, + x == 'rarely' ~ 0.1, + x == "never" ~ 0 + ) +} + #' Scores to frequency #' #' \code{scores2Freq} converts numeric scores, stored in the "Score" column in diff --git a/man/freq2Scores2.Rd b/man/freq2Scores2.Rd new file mode 100644 index 0000000..ccc8925 --- /dev/null +++ b/man/freq2Scores2.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{freq2Scores2} +\alias{freq2Scores2} +\title{Frequency to scores 2} +\usage{ +freq2Scores2(x) +} +\arguments{ +\item{x}{A character vector.} +} +\value{ +A numeric vector. +} +\description{ +\code{freq2Scores} converts the keywords in the "Frequency" +column of a bugphyzz dataset into numeric scores, which are interpreted +as probabilities. This v2 should be used after performing ASR in +numeric attributes. +}