mirror of
https://github.com/msberends/AMR.git
synced 2025-07-08 14:01:55 +02:00
add shortest and longest to freq for characters
This commit is contained in:
9
R/freq.R
9
R/freq.R
@ -315,6 +315,9 @@ frequency_tbl <- function(x,
|
||||
header <- header %>% paste0(markdown_line, 'Columns: ', mult.columns)
|
||||
} else {
|
||||
header <- header %>% paste0(markdown_line, 'Class: ', class(x) %>% rev() %>% paste(collapse = " > "))
|
||||
if (!mode(x) %in% class(x)) {
|
||||
header <- header %>% paste0(" (", mode(x), ")")
|
||||
}
|
||||
}
|
||||
|
||||
header <- header %>% paste0(markdown_line, '\nLength: ', (NAs %>% length() + x %>% length()) %>% format(),
|
||||
@ -322,6 +325,12 @@ frequency_tbl <- function(x,
|
||||
' = ', (NAs %>% length() / (NAs %>% length() + x %>% length())) %>% percent(force_zero = TRUE, round = digits) %>% sub('NaN', '0', ., fixed = TRUE), ')')
|
||||
header <- header %>% paste0(markdown_line, '\nUnique: ', x %>% n_distinct() %>% format())
|
||||
|
||||
if (NROW(x) > 0 & any(class(x) == "character")) {
|
||||
header <- header %>% paste0('\n')
|
||||
header <- header %>% paste0(markdown_line, '\nShortest: ', x %>% base::nchar() %>% base::min(na.rm = TRUE))
|
||||
header <- header %>% paste0(markdown_line, '\nLongest: ', x %>% base::nchar() %>% base::max(na.rm = TRUE))
|
||||
}
|
||||
|
||||
if (NROW(x) > 0 & any(class(x) %in% c('double', 'integer', 'numeric', 'raw', 'single'))) {
|
||||
# right align number
|
||||
Tukey_five <- stats::fivenum(x, na.rm = TRUE)
|
||||
|
Reference in New Issue
Block a user