Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Long2short (#145)
Browse files Browse the repository at this point in the history
* long name to short name

* update the documentation

* typo

* update manual
  • Loading branch information
sinanshi authored Nov 12, 2017
1 parent 951f277 commit 6bcb7e5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export(is.drugs)
export(is.laboratory)
export(is.physiology)
export(lenstay)
export(long2stname)
export(lookup.items)
export(new.episode)
export(physio.distribution)
Expand Down
12 changes: 12 additions & 0 deletions R/stdid.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down
2 changes: 2 additions & 0 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
longnames <- vapply(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 <- vapply(ITEM_REF, function(x) x$Classification1, "")
Expand All @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions man/long2stname.Rd

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

0 comments on commit 6bcb7e5

Please sign in to comment.