Skip to content

Commit

Permalink
Add freq2SCores2 function.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdgamboa committed Apr 3, 2024
1 parent 76e0e02 commit ec023d9
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(filterData)
export(filterDataDiscrete)
export(filterDataNumeric)
export(freq2Scores)
export(freq2Scores2)
export(getDataReady)
export(getNsti)
export(getSetWithIDs)
Expand Down
24 changes: 24 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions man/freq2Scores2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec023d9

Please sign in to comment.