Formatting setter for selected numerical statistics
Value
list:
fmt : named vector with formatting function (jjcsformat_xx) for numerical stats: range, median, mean_sd, sd
spec : named vector with formatting specifications for numerical stats: range, median, mean_sd, sd
Examples
P1_precision <- jjcs_num_formats(d=0)$fmt
jjcs_num_formats(2)$fmt
#> $range
#> function (x, output, na_str = na_str_dflt)
#> {
#> if (anyNA(na_str) || (replace_na_dflt && any(na_str == "NA"))) {
#> na_inds <- which(is.na(na_str) | (replace_na_dflt & na_str ==
#> "NA"))
#> na_str[na_inds] <- rep(na_str_dflt, length.out = length(na_str))[na_inds]
#> }
#> if (length(x) == 0 || isTRUE(all(x == ""))) {
#> return(NULL)
#> }
#> else if (!length(positions[[1]]) == length(x)) {
#> stop("Error: input str in call to jjcs_format_xx must contain same number of xx as the number of stats.")
#> }
#> values <- Map(y = x, fun = roundings, na_str = na_str, function(y,
#> fun, na_str) fun(y, na_str = na_str))
#> regmatches(x = str, m = positions)[[1]] <- values
#> return(str)
#> }
#> <bytecode: 0x55fa0c3a37f8>
#> <environment: 0x55fa0b28f3d8>
#>
#> $mean_sd
#> function (x, output, na_str = na_str_dflt)
#> {
#> if (anyNA(na_str) || (replace_na_dflt && any(na_str == "NA"))) {
#> na_inds <- which(is.na(na_str) | (replace_na_dflt & na_str ==
#> "NA"))
#> na_str[na_inds] <- rep(na_str_dflt, length.out = length(na_str))[na_inds]
#> }
#> if (length(x) == 0 || isTRUE(all(x == ""))) {
#> return(NULL)
#> }
#> else if (!length(positions[[1]]) == length(x)) {
#> stop("Error: input str in call to jjcs_format_xx must contain same number of xx as the number of stats.")
#> }
#> values <- Map(y = x, fun = roundings, na_str = na_str, function(y,
#> fun, na_str) fun(y, na_str = na_str))
#> regmatches(x = str, m = positions)[[1]] <- values
#> return(str)
#> }
#> <bytecode: 0x55fa0c3a37f8>
#> <environment: 0x55fa0b2a0160>
#>
#> $sd
#> function (x, output, na_str = na_str_dflt)
#> {
#> if (anyNA(na_str) || (replace_na_dflt && any(na_str == "NA"))) {
#> na_inds <- which(is.na(na_str) | (replace_na_dflt & na_str ==
#> "NA"))
#> na_str[na_inds] <- rep(na_str_dflt, length.out = length(na_str))[na_inds]
#> }
#> if (length(x) == 0 || isTRUE(all(x == ""))) {
#> return(NULL)
#> }
#> else if (!length(positions[[1]]) == length(x)) {
#> stop("Error: input str in call to jjcs_format_xx must contain same number of xx as the number of stats.")
#> }
#> values <- Map(y = x, fun = roundings, na_str = na_str, function(y,
#> fun, na_str) fun(y, na_str = na_str))
#> regmatches(x = str, m = positions)[[1]] <- values
#> return(str)
#> }
#> <bytecode: 0x55fa0c3a37f8>
#> <environment: 0x55fa0b2a9360>
#>
#> $median
#> function (x, output, na_str = na_str_dflt)
#> {
#> if (anyNA(na_str) || (replace_na_dflt && any(na_str == "NA"))) {
#> na_inds <- which(is.na(na_str) | (replace_na_dflt & na_str ==
#> "NA"))
#> na_str[na_inds] <- rep(na_str_dflt, length.out = length(na_str))[na_inds]
#> }
#> if (length(x) == 0 || isTRUE(all(x == ""))) {
#> return(NULL)
#> }
#> else if (!length(positions[[1]]) == length(x)) {
#> stop("Error: input str in call to jjcs_format_xx must contain same number of xx as the number of stats.")
#> }
#> values <- Map(y = x, fun = roundings, na_str = na_str, function(y,
#> fun, na_str) fun(y, na_str = na_str))
#> regmatches(x = str, m = positions)[[1]] <- values
#> return(str)
#> }
#> <bytecode: 0x55fa0c3a37f8>
#> <environment: 0x55fa0b2b2d78>
#>
jjcs_num_formats(2)$spec
#> range mean_sd sd median
#> "xx.xx, xx.xx" "xx.xxx (xx.xxxx)" "xx.xxxx" "xx.xxx"