1
0
mirror of https://github.com/msberends/AMR.git synced 2025-07-08 10:31:53 +02:00

(v1.4.0.9034) MIC printing update

This commit is contained in:
2020-12-09 09:40:50 +01:00
parent 2145f1d1ba
commit c9fc7e8a45
31 changed files with 178 additions and 174 deletions

14
R/mic.R
View File

@ -155,21 +155,21 @@ is.mic <- function(x) {
#' @export
#' @noRd
as.double.mic <- function(x, ...) {
as.double(gsub("(<|=|>)+", "", as.character(x)))
as.double(gsub("[<=>]+", "", as.character(x)))
}
#' @method as.integer mic
#' @export
#' @noRd
as.integer.mic <- function(x, ...) {
as.integer(gsub("(<|=|>)+", "", as.character(x)))
as.integer(gsub("[<=>]+", "", as.character(x)))
}
#' @method as.numeric mic
#' @export
#' @noRd
as.numeric.mic <- function(x, ...) {
as.numeric(gsub("(<|=|>)+", "", as.character(x)))
as.numeric(gsub("[<=>]+", "", as.character(x)))
}
#' @method droplevels mic
@ -183,9 +183,13 @@ droplevels.mic <- function(x, exclude = ifelse(anyNA(levels(x)), NULL, NA), ...)
# will be exported using s3_register() in R/zzz.R
pillar_shaft.mic <- function(x, ...) {
out <- trimws(format(x))
crude_numbers <- as.double(x)
operators <- gsub("[^<=>]+", "", as.character(x))
pasted <- trimws(paste0(operators, trimws(format(crude_numbers))))
out <- pasted
out[is.na(x)] <- font_na(NA)
create_pillar_column(out, align = "right", min_width = 4)
out <- gsub("(<|=|>)", font_silver("\\1"), out)
create_pillar_column(out, align = "right", width = max(nchar(pasted)))
}
# will be exported using s3_register() in R/zzz.R