diff --git a/NAMESPACE b/NAMESPACE index f7a0b1c..0f79a1d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -25,6 +25,7 @@ export(is.drugs) export(is.laboratory) export(is.physiology) export(lenstay) +export(long2stname) export(lookup.items) export(new.episode) export(physio.distribution) diff --git a/R/stdid.R b/R/stdid.R index 082318a..d43210e 100644 --- a/R/stdid.R +++ b/R/stdid.R @@ -86,6 +86,18 @@ stname2longname <- function(stname) { return(code) } +#' Convert long names to short names. +#' +#' @param l long name such as "heart rate" +#' @return short name character such as "h_rate" +#' @export +long2stname <- function(l) { + l <- as.character(l) + s <- long2stname.dict[l] + s[is.na(s)] <- l[is.na(s)] + return(s) +} + #' Identify the classification - classification1 #' diff --git a/R/zzz.R b/R/zzz.R index 9750c54..6fcdbfd 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -34,6 +34,7 @@ longnames <- sapply(ITEM_REF, function(x) x$dataItem) stname2longname.dict <- longnames names(stname2longname.dict) <- stname + long2stname.dict <- reverse.name.value(stname2longname.dict) #' classification dictionary: demographic, nurse, physiology, laboratory, drugs class.dict_code <- sapply(ITEM_REF, function(x) x$Classification1) @@ -50,6 +51,7 @@ assign("code2stname.dict" , code2stname.dict , envir=env) assign("stname2code.dict" , stname2code.dict , envir=env) assign("stname2longname.dict" , stname2longname.dict , envir=env) + assign("long2stname.dict" , long2stname.dict , envir=env) assign("class.dict_code" , class.dict_code , envir=env) assign("class.dict_stname", class.dict_stname, envir=env) assign("tval.dict_code" , tval.dict_code , envir=env) diff --git a/man/lenstay.Rd b/man/lenstay.Rd index 347bdc2..8fe7073 100644 --- a/man/lenstay.Rd +++ b/man/lenstay.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/demographics.R \name{lenstay} \alias{lenstay} -\title{Calculate the lenght of stay in the ICU.} +\title{Calculate the length of stay in the ICU.} \usage{ lenstay(demg, units = "hours") } @@ -17,7 +17,7 @@ data.table It is the original data.table with lenstay column (in difftime) appended. } \description{ -Calculate the lenght of stay in the ICU and append it to the original demographic +Calculate the length of stay in the ICU and append it to the original demographic table. } diff --git a/man/long2stname.Rd b/man/long2stname.Rd new file mode 100644 index 0000000..8755cab --- /dev/null +++ b/man/long2stname.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stdid.R +\name{long2stname} +\alias{long2stname} +\title{Convert long names to short names.} +\usage{ +long2stname(l) +} +\arguments{ +\item{l}{long name such as "heart rate"} +} +\value{ +short name character such as "h_rate" +} +\description{ +Convert long names to short names. +} +