jackwasey / icd

@@ -24,7 +24,7 @@
Loading
24 24
  assert_int(n_comorbidities)
25 25
  assert_int(n_codes)
26 26
  get_n_or_len <- function(x, n) {
27 -
    x[1:ifelse(length(x) < n, length(x), n)]
27 +
    x[seq_len(ifelse(length(x) < n, length(x), n))]
28 28
  }
29 29
  message(
30 30
    "Showing first ",

@@ -168,10 +168,21 @@
Loading
168 168
#' @keywords internal
169 169
#' @noRd
170 170
icd_classes_conflict <- function(x) {
171 -
  is.icd9(x) && is.icd10(x) ||
172 -
    is.icd9cm(x) && is.icd9cm_pc(x) ||
173 -
    is.icd10cm(x) && is.icd10cm_pc(x) ||
174 -
    is.icd_long_data(x) && is.icd_wide_data(x)
171 +
  if (is.icd9(x) && is.icd10(x)) {
172 +
    return(TRUE)
173 +
  }
174 +
175 +
  if (is.icd9cm(x) && is.icd9cm_pc(x)
176 +
  ) {
177 +
    return(TRUE)
178 +
  }
179 +
  if (is.icd10cm(x) && is.icd10cm_pc(x)) {
180 +
    return(TRUE)
181 +
  }
182 +
  if (is.icd_long_data(x) && is.icd_wide_data(x)) {
183 +
    return(TRUE)
184 +
  }
185 +
  return(FALSE)
175 186
}
176 187
177 188
#' Prefer an order of classes

@@ -12,8 +12,10 @@
Loading
12 12
13 13
using namespace Rcpp;
14 14
15 -
// [[Rcpp::export(icd10_short_to_parts_rcpp)]]
16 -
List icd10ShortToParts(const CV &x, const String& mnrEmpty) {
15 +
// //Rcpp::export(icd10_short_to_parts_rcpp)]]
16 +
17 +
// [[Rcpp::export]]
18 +
Rcpp::List icd10ShortToParts(const Rcpp::CharacterVector & x, const Rcpp::String & mnrEmpty) {
17 19
  R_xlen_t i10sz = x.size();
18 20
  CV mjr(i10sz);
19 21
  CV mnr(i10sz);
@@ -43,7 +45,7 @@
Loading
43 45
}
44 46
45 47
// [[Rcpp::export]]
46 -
List icd10DecimalToParts(const CV& x, const String& mnrEmpty = "") {
48 +
List icd10DecimalToParts(const CV & x, const String & mnrEmpty) {
47 49
  CV mjrs;
48 50
  CV mnrs;
49 51
  R_xlen_t ilen = x.length();

@@ -39,6 +39,8 @@
Loading
39 39
#' @noRd
40 40
.parse_icd9cm_rtf_year <- function(year = "2014",
41 41
                                   save_pkg_majors = FALSE) {
42 +
  code <- NULL
43 +
  three_digit <- NULL
42 44
  year <- as.character(year)
43 45
  stopifnot(year %in% .icd9cm_sources$f_year)
44 46
  f_info_rtf <- .dl_icd9cm_rtf_year(year)

@@ -10,7 +10,7 @@
Loading
10 10
#' \dontrun{
11 11
#' # get function from namespace instead of possibly getting
12 12
#' # implementation shipped with recent R versions:
13 -
#' f = getFromNamespace("R_user_dir", "icd")
13 +
#' f <- getFromNamespace("R_user_dir", "icd")
14 14
#' cached <- f("icd", "cache")
15 15
#' confd <- f("icd", "config")
16 16
#' datad <- f("icd", "data")
@@ -38,44 +38,54 @@
Loading
38 38
  path <-
39 39
    switch(which,
40 40
      data = {
41 -
        if(nzchar(p <- Sys.getenv("R_USER_DATA_DIR")))
41 +
        if (nzchar(p <- Sys.getenv("R_USER_DATA_DIR"))) {
42 42
          p
43 -
        else if(nzchar(p <- Sys.getenv("XDG_DATA_HOME")))
43 +
        } else if (nzchar(p <- Sys.getenv("XDG_DATA_HOME"))) {
44 44
          p
45 -
        else if(.Platform$OS.type == "windows")
45 +
        } else if (.Platform$OS.type == "windows") {
46 46
          file.path(Sys.getenv("APPDATA"), "R", "data")
47 -
        else if(Sys.info()["sysname"] == "Darwin")
48 -
          file.path(home, "Library", "Application Support",
49 -
            "org.R-project.R")
50 -
        else
47 +
        } else if (Sys.info()["sysname"] == "Darwin") {
48 +
          file.path(
49 +
            home, "Library", "Application Support",
50 +
            "org.R-project.R"
51 +
          )
52 +
        } else {
51 53
          file.path(home, ".local", "share")
54 +
        }
52 55
      },
53 56
      config = {
54 -
        if(nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR")))
57 +
        if (nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR"))) {
55 58
          p
56 -
        else if(nzchar(p <- Sys.getenv("XDG_CONFIG_HOME")))
59 +
        } else if (nzchar(p <- Sys.getenv("XDG_CONFIG_HOME"))) {
57 60
          p
58 -
        else if(.Platform$OS.type == "windows")
61 +
        } else if (.Platform$OS.type == "windows") {
59 62
          file.path(Sys.getenv("APPDATA"), "R", "config")
60 -
        else if(Sys.info()["sysname"] == "Darwin")
61 -
          file.path(home, "Library", "Preferences",
62 -
            "org.R-project.R")
63 -
        else
63 +
        } else if (Sys.info()["sysname"] == "Darwin") {
64 +
          file.path(
65 +
            home, "Library", "Preferences",
66 +
            "org.R-project.R"
67 +
          )
68 +
        } else {
64 69
          file.path(home, ".config")
70 +
        }
65 71
      },
66 72
      cache = {
67 -
        if(nzchar(p <- Sys.getenv("R_USER_CACHE_DIR")))
73 +
        if (nzchar(p <- Sys.getenv("R_USER_CACHE_DIR"))) {
68 74
          p
69 -
        else if(nzchar(p <- Sys.getenv("XDG_CACHE_HOME")))
75 +
        } else if (nzchar(p <- Sys.getenv("XDG_CACHE_HOME"))) {
70 76
          p
71 -
        else if(.Platform$OS.type == "windows")
77 +
        } else if (.Platform$OS.type == "windows") {
72 78
          file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache")
73 -
        else if(Sys.info()["sysname"] == "Darwin")
74 -
          file.path(home, "Library", "Caches",
75 -
            "org.R-project.R")
76 -
        else
79 +
        } else if (Sys.info()["sysname"] == "Darwin") {
80 +
          file.path(
81 +
            home, "Library", "Caches",
82 +
            "org.R-project.R"
83 +
          )
84 +
        } else {
77 85
          file.path(home, ".cache")
78 -
      })
86 +
        }
87 +
      }
88 +
    )
79 89
80 90
  file.path(path, "R", package)
81 91
}

@@ -4,7 +4,7 @@
Loading
4 4
#' and forms the core of the package, along with the C++ matrix code. This is
5 5
#' pure data manipulation and generalizable beyond medical data.
6 6
#'
7 -
#' The roadmap for \CRANpkg{icd} includes the optimized categorization component
7 +
#' The goals for \CRANpkg{icd} include the optimized categorization component
8 8
#' being packaged independently, and the comorbidity package taking on the
9 9
#' front-end for doing ICD-code-based comorbidities. This is in discussion.
10 10
#' @param x Data frame containing a column for an 'id' and a column for a code,

@@ -394,7 +394,7 @@
Loading
394 394
#' @keywords internal manip
395 395
#' @noRd
396 396
short_to_parts.icd10 <- function(x, mnr_empty = "") {
397 -
  icd10_short_to_parts_rcpp(x, mnrEmpty = mnr_empty)
397 +
  icd10ShortToParts(x, mnrEmpty = mnr_empty)
398 398
}
399 399
400 400
#' @describeIn short_to_parts Convert short format ICD-10-CM codes to parts
@@ -402,7 +402,7 @@
Loading
402 402
#' @keywords internal manip
403 403
#' @noRd
404 404
short_to_parts.icd10cm <- function(x, mnr_empty = "") {
405 -
  icd10_short_to_parts_rcpp(x, mnrEmpty = mnr_empty)
405 +
  short_to_parts.icd10(x, mnr_empty)
406 406
}
407 407
408 408
#' @describeIn short_to_parts Convert short format ICD code to parts,

@@ -51,7 +51,7 @@
Loading
51 51
    stopifnot(length(x) == 1)
52 52
    x <- x[[1]]
53 53
  }
54 -
  y <- as_char_no_warn(x)[1:min(n, length(x))]
54 +
  y <- as_char_no_warn(x)[seq_len(min(n, length(x)))]
55 55
  if (!is.null(short_code)) {
56 56
    if (short_code) {
57 57
      i9 <- sum(is_valid.icd9(y, short_code = TRUE), na.rm = TRUE)
@@ -75,7 +75,7 @@
Loading
75 75
}
76 76
77 77
get_icd_defined_percent <- function(x, short_code = NULL, n = 100) {
78 -
  y <- as_char_no_warn(x)[1:min(n, length(x))]
78 +
  y <- as_char_no_warn(x)[seq_len(min(n, length(x)))]
79 79
  if (!is.null(short_code)) {
80 80
    if (short_code) {
81 81
      i9 <- sum(is_defined.icd9(y, short_code = TRUE), na.rm = TRUE)

@@ -113,11 +113,6 @@
Loading
113 113
  res
114 114
}
115 115
116 -
# simple backport
117 -
isFALSE <- function(x) {
118 -
  is.logical(x) && length(x) == 1L && !is.na(x) && !x
119 -
}
120 -
121 116
#' @rdname sort_icd
122 117
#' @export
123 118
order.icd9 <- function(x, na.last = TRUE) {
Files Coverage
R 49.50%
src 87.55%
Project Totals (73 files) 55.87%
1
comment:
2
  layout: "header, diff, tree, changes"
3
  behavior: default
4
  require_changes: true  # only post if coverage changes
5
  branches: null
6
  flags: null
7
  paths: null
8

9
coverage:
10
  status:
11
    project:
12
      default:
13
        target: auto
14
        threshold: 1%
15
    patch:
16
      default:
17
        target: auto
18
        threshold: 1%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading