Skip to content

Commit

Permalink
Added mean and variance to count data tables in fitting module
Browse files Browse the repository at this point in the history
  • Loading branch information
aldomann committed Oct 26, 2019
1 parent 9d38bed commit 9dbefcf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions inst/app/modules/generalFittingModules.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ generalFittingCountsHotTable <- function(input, output, session, stringsAsFactor
dplyr::mutate(
N = 0,
X = 0,
mean = 0,
var = 0,
DI = 0,
u = 0
) %>%
Expand Down Expand Up @@ -150,16 +152,17 @@ generalFittingCountsHotTable <- function(input, output, session, stringsAsFactor
N = as.integer(rowSums(.[grep("C", names(.))])),
X = aberr_calc(mytable, power = 1),
X2 = aberr_calc(mytable, power = 2),
var = (X2 - (X^2) / N) / (N - 1),
mean = X / N,
var = (X2 - (X^2) / N) / (N - 1),
DI = var / mean,
u = (var / mean - assessment_u) * sqrt( (N - 1) / (2 * (1 - 1 / X)))
) %>%
dplyr::mutate_at(
c("X", "N", grep("C", names(.), value = TRUE)),
as.integer
) %>%
dplyr::select(-X2, -var, -mean) %>%
# dplyr::select(-X2, -var, -mean) %>%
dplyr::select(-X2) %>%
dplyr::select(D, N, X, everything())
} else {
mytable <- mytable %>%
Expand Down Expand Up @@ -188,7 +191,7 @@ generalFittingCountsHotTable <- function(input, output, session, stringsAsFactor

if (num_cols > 3) {
hot <- hot %>%
hot_col(c(2, 3, seq(num_cols - 1, num_cols, 1)), readOnly = TRUE) %>%
hot_col(c(2, 3, seq(num_cols - 3, num_cols, 1)), readOnly = TRUE) %>%
hot_col(num_cols, renderer = "
function (instance, td, row, col, prop, value, cellProperties) {
Handsontable.renderers.NumericRenderer.apply(this, arguments);
Expand Down

0 comments on commit 9dbefcf

Please sign in to comment.