From 49e4be85582acae8427bfdde1ecad0c7dc089914 Mon Sep 17 00:00:00 2001 From: sdgamboa Date: Wed, 3 Apr 2024 17:32:15 -0400 Subject: [PATCH] Add nsti2Freq function. --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/utils.R | 20 ++++++++++++++++++++ man/nsti2Freq.Rd | 17 +++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 man/nsti2Freq.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 515222a..1cb7863 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: taxPPro Type: Package Title: Taxonomic and phylogenetic propagation for bugphyzz -Version: 0.99.0 +Version: 0.99.1 Authors@R: c( person( diff --git a/NAMESPACE b/NAMESPACE index d1be678..445c420 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,5 +14,6 @@ export(getNsti) export(getSetWithIDs) export(getSetWithoutIDs) export(ltp) +export(nsti2Freq) export(roundDec) export(scores2Freq) diff --git a/R/utils.R b/R/utils.R index 5fb1270..d08a882 100644 --- a/R/utils.R +++ b/R/utils.R @@ -159,3 +159,23 @@ roundDec <- function(x) { ceiling(((1 / n) + 1e-06) * 10) / 10 } + +#' NSTI to Frequency +#' +#' \code{nsti2Freq} converts nsti values to frequencuy keywords. +#' +#' @param x A numeric vectir of nsti values +#' +#' @return A character vector of frequency keywords. +#' @export +#' +nsti2Freq <- function(x) { + dplyr::case_when( + is.na(x) ~ NA, + x == 0 ~ "always", + x > 0 & x <= 0.05 ~ "usually", + x > 0.05 & x <= 0.15 ~ "sometimes", + x > 0.15 & x <= 0.2 ~ "rarely", + x > 0.2 ~ "never" + ) +} diff --git a/man/nsti2Freq.Rd b/man/nsti2Freq.Rd new file mode 100644 index 0000000..a45c868 --- /dev/null +++ b/man/nsti2Freq.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{nsti2Freq} +\alias{nsti2Freq} +\title{NSTI to Frequency} +\usage{ +nsti2Freq(x) +} +\arguments{ +\item{x}{A numeric vectir of nsti values} +} +\value{ +A character vector of frequency keywords. +} +\description{ +\code{nsti2Freq} converts nsti values to frequencuy keywords. +}