twolodzko / kernelboot
Showing 1 of 6 files from the diff.
Other files ignored by Codecov

@@ -303,23 +303,23 @@
Loading
303 303
  if (!(is.simple.vector(data) || is.data.frame(data) || is.matrix(data)))
304 304
    stop("unsupported data type")
305 305
306 +
  if (is.data.frame(data) || is.matrix(data)) {
307 +
    # data is data.frame or matrix
308 +
309 +
    num_cols <- numericColumns(data)             # find numeric columns
310 +
    ignr_cols <- colnames(data) %in% ignore
311 +
    incl_cols <- num_cols & !ignr_cols
312 +
  }
313 +
306 314
  if (is.character(bw)) {
307 -
    bw <- tolower(bw)
308 -
    if (bw == "default") {
309 -
      if (is.simple.vector(data)) {
310 -
        bw <- bw.nrd0(data)
311 -
      } else {
312 -
        bw <- bw.silv(data)
313 -
        if (kernel != "multivariate")
314 -
          bw <- sqrt(diag(bw))
315 -
      }
315 +
    if (is.data.frame(data) || is.matrix(data)) {
316 +
      method <- bw
317 +
      bw <- matrix(0, m, m)
318 +
      if (!is.null(colnames(data)))
319 +
        rownames(bw) <- colnames(bw) <- colnames(data)
320 +
      bw[incl_cols, incl_cols] <- calculate_bandwidth(data[, incl_cols], method, kernel)
316 321
    } else {
317 -
      bw <- switch(bw, nrd0 = bw.nrd0(data), nrd = bw.nrd(data),
318 -
                   ucv = bw.ucv(data), bcv = bw.bcv(data), sj = ,
319 -
                   `sj-ste` = bw.SJ(data, method = "ste"),
320 -
                   `sj-dpi` = bw.SJ(data, method = "dpi"),
321 -
                   silv = bw.silv(data), scott = bw.scott(data),
322 -
                   stop("unknown bandwidth rule"))
322 +
      bw <- calculate_bandwidth(data, bw, kernel)
323 323
    }
324 324
  }
325 325
@@ -370,12 +370,6 @@
Loading
370 370
371 371
  if (is.data.frame(data) || is.matrix(data)) {
372 372
373 -
    # data is data.frame or matrix
374 -
375 -
    num_cols <- numericColumns(data)             # find numeric columns
376 -
    ignr_cols <- colnames(data) %in% ignore
377 -
    incl_cols <- num_cols & !ignr_cols
378 -
379 373
    if (!is.null(colnames(data))) {
380 374
      vars <- list(
381 375
        smoothed = colnames(data)[incl_cols],
@@ -561,3 +555,24 @@
Loading
561 555
562 556
}
563 557
558 +
559 +
calculate_bandwidth <- function(data, bw, kernel) {
560 +
  bw <- tolower(bw)
561 +
  if (bw == "default") {
562 +
    if (is.simple.vector(data)) {
563 +
      bw <- bw.nrd0(data)
564 +
    } else {
565 +
      bw <- bw.silv(data)
566 +
      if (kernel != "multivariate")
567 +
        bw <- sqrt(diag(bw))
568 +
    }
569 +
  } else {
570 +
    bw <- switch(bw, nrd0 = bw.nrd0(data), nrd = bw.nrd(data),
571 +
                 ucv = bw.ucv(data), bcv = bw.bcv(data), sj = ,
572 +
                 `sj-ste` = bw.SJ(data, method = "ste"),
573 +
                 `sj-dpi` = bw.SJ(data, method = "dpi"),
574 +
                 silv = bw.silv(data), scott = bw.scott(data),
575 +
                 stop("unknown bandwidth rule"))
576 +
  }
577 +
  return(bw)
578 +
}
Files Coverage
R 90.16%
src 96.95%
Project Totals (12 files) 92.82%
Notifications are pending CI completion. Waiting for GitHub's status webhook to queue notifications. Push notifications now.
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