mirror of
https://github.com/msberends/AMR.git
synced 2025-07-09 02:03:04 +02:00
fix for macOS and older tidyr versions
This commit is contained in:
15
R/freq.R
15
R/freq.R
@ -166,18 +166,11 @@ frequency_tbl <- function(x,
|
||||
if (!"tidyr" %in% rownames(installed.packages())) {
|
||||
stop('transformation from `table` to frequency table requires the tidyr package.', call. = FALSE)
|
||||
}
|
||||
values <- x %>%
|
||||
x <- x %>%
|
||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||
# delete last variable: these are frequencies
|
||||
select(-ncol(.)) %>%
|
||||
# paste all other columns:
|
||||
tidyr::unite(sep = sep) %>%
|
||||
.[, 1]
|
||||
counts <- x %>%
|
||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||
# get last variable: these are frequencies
|
||||
pull(ncol(.))
|
||||
x <- rep(values, counts)
|
||||
# paste first two columns
|
||||
tidyr::unite(col = "Pasted", 1:2, sep = sep, remove = TRUE)
|
||||
x <- rep(x %>% pull(Pasted), x %>% pull(Freq))
|
||||
x.name <- "a `table` object"
|
||||
cols <- NULL
|
||||
mult.columns <- 2
|
||||
|
@ -30,6 +30,7 @@ globalVariables(c('abname',
|
||||
'days_diff',
|
||||
'fctlvl',
|
||||
'first_isolate_row_index',
|
||||
'Freq',
|
||||
'fullname',
|
||||
'genus',
|
||||
'gramstain',
|
||||
@ -46,6 +47,7 @@ globalVariables(c('abname',
|
||||
'n',
|
||||
'na.omit',
|
||||
'other_pat_or_mo',
|
||||
'Pasted',
|
||||
'patient_id',
|
||||
'quantile',
|
||||
'real_first_isolate',
|
||||
|
Reference in New Issue
Block a user