1
0
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:
2018-07-11 12:34:02 +02:00
parent eca406b18b
commit e3e10c2e88
4 changed files with 9 additions and 16 deletions

View File

@ -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

View File

@ -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',