From 31d38dfa49b8beeebc9d897cfaa74208b4e4d2b3 Mon Sep 17 00:00:00 2001 From: sdgamboa Date: Thu, 28 Sep 2023 15:18:16 -0400 Subject: [PATCH] add function for converting confidence_in_curation to factor --- NAMESPACE | 1 + R/utils.R | 16 ++++++++++++++++ man/conf2Fct.Rd | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 man/conf2Fct.Rd diff --git a/NAMESPACE b/NAMESPACE index 1743ac8..486e108 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -14,6 +14,7 @@ export(calcParentScores) export(chooseColVal) export(classif2Table) export(cleanNode) +export(conf2Fct) export(fillNAs) export(freq2Scores) export(getAgreements) diff --git a/R/utils.R b/R/utils.R index 4a97d22..1a8b569 100644 --- a/R/utils.R +++ b/R/utils.R @@ -41,6 +41,22 @@ scores2Freq <- function(x) { ) } + +#' Confidence in curation to factor +#' +#' \code{conf2Fct} converts a vector from the Confidence_in_curation +#' column in a bugphyzz dataset to a factor. +#' +#' @param x A character vector. +#' +#' @return A factor. +#' +#' @export +#' +conf2Fct <- function(x) { + factor(x, levels = c('low', 'medium', 'high'), ordered = TRUE) +} + ## Function with valid ranks for taxa .validRanks <- function() { c('strain', 'species', 'genus', 'family', 'order', 'class', 'phylum', diff --git a/man/conf2Fct.Rd b/man/conf2Fct.Rd new file mode 100644 index 0000000..c4ba097 --- /dev/null +++ b/man/conf2Fct.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/utils.R +\name{conf2Fct} +\alias{conf2Fct} +\title{Confidence in curation to factor} +\usage{ +conf2Fct(x) +} +\arguments{ +\item{x}{A character vector.} +} +\value{ +A factor. +} +\description{ +\code{conf2Fct} converts a vector from the Confidence_in_curation +column in a bugphyzz dataset to a factor. +}