mirror of
https://github.com/msberends/AMR.git
synced 2024-12-26 05:26:13 +01:00
fix for macOS and older tidyr versions
This commit is contained in:
parent
eca406b18b
commit
e3e10c2e88
@ -1,6 +1,6 @@
|
|||||||
Package: AMR
|
Package: AMR
|
||||||
Version: 0.2.0.9010
|
Version: 0.2.0.9010
|
||||||
Date: 2018-07-10
|
Date: 2018-07-11
|
||||||
Title: Antimicrobial Resistance Analysis
|
Title: Antimicrobial Resistance Analysis
|
||||||
Authors@R: c(
|
Authors@R: c(
|
||||||
person(
|
person(
|
||||||
@ -44,7 +44,7 @@ Suggests:
|
|||||||
covr (>= 3.0.1),
|
covr (>= 3.0.1),
|
||||||
rmarkdown,
|
rmarkdown,
|
||||||
rstudioapi,
|
rstudioapi,
|
||||||
tidyr (>= 0.8.0)
|
tidyr
|
||||||
VignetteBuilder: knitr
|
VignetteBuilder: knitr
|
||||||
URL: https://github.com/msberends/AMR
|
URL: https://github.com/msberends/AMR
|
||||||
BugReports: https://github.com/msberends/AMR/issues
|
BugReports: https://github.com/msberends/AMR/issues
|
||||||
|
15
R/freq.R
15
R/freq.R
@ -166,18 +166,11 @@ frequency_tbl <- function(x,
|
|||||||
if (!"tidyr" %in% rownames(installed.packages())) {
|
if (!"tidyr" %in% rownames(installed.packages())) {
|
||||||
stop('transformation from `table` to frequency table requires the tidyr package.', call. = FALSE)
|
stop('transformation from `table` to frequency table requires the tidyr package.', call. = FALSE)
|
||||||
}
|
}
|
||||||
values <- x %>%
|
x <- x %>%
|
||||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
as.data.frame(stringsAsFactors = FALSE) %>%
|
||||||
# delete last variable: these are frequencies
|
# paste first two columns
|
||||||
select(-ncol(.)) %>%
|
tidyr::unite(col = "Pasted", 1:2, sep = sep, remove = TRUE)
|
||||||
# paste all other columns:
|
x <- rep(x %>% pull(Pasted), x %>% pull(Freq))
|
||||||
tidyr::unite(sep = sep) %>%
|
|
||||||
.[, 1]
|
|
||||||
counts <- x %>%
|
|
||||||
as.data.frame(stringsAsFactors = FALSE) %>%
|
|
||||||
# get last variable: these are frequencies
|
|
||||||
pull(ncol(.))
|
|
||||||
x <- rep(values, counts)
|
|
||||||
x.name <- "a `table` object"
|
x.name <- "a `table` object"
|
||||||
cols <- NULL
|
cols <- NULL
|
||||||
mult.columns <- 2
|
mult.columns <- 2
|
||||||
|
@ -30,6 +30,7 @@ globalVariables(c('abname',
|
|||||||
'days_diff',
|
'days_diff',
|
||||||
'fctlvl',
|
'fctlvl',
|
||||||
'first_isolate_row_index',
|
'first_isolate_row_index',
|
||||||
|
'Freq',
|
||||||
'fullname',
|
'fullname',
|
||||||
'genus',
|
'genus',
|
||||||
'gramstain',
|
'gramstain',
|
||||||
@ -46,6 +47,7 @@ globalVariables(c('abname',
|
|||||||
'n',
|
'n',
|
||||||
'na.omit',
|
'na.omit',
|
||||||
'other_pat_or_mo',
|
'other_pat_or_mo',
|
||||||
|
'Pasted',
|
||||||
'patient_id',
|
'patient_id',
|
||||||
'quantile',
|
'quantile',
|
||||||
'real_first_isolate',
|
'real_first_isolate',
|
||||||
|
@ -18,9 +18,7 @@ test_that("frequency table works", {
|
|||||||
# factor
|
# factor
|
||||||
expect_output(print(freq(septic_patients$hospital_id)))
|
expect_output(print(freq(septic_patients$hospital_id)))
|
||||||
# table
|
# table
|
||||||
#if (Sys.info()['sysname'] %in% c("Windows", "Linux")) {
|
|
||||||
expect_output(print(freq(table(septic_patients$sex, septic_patients$age))))
|
expect_output(print(freq(table(septic_patients$sex, septic_patients$age))))
|
||||||
#}
|
|
||||||
|
|
||||||
library(dplyr)
|
library(dplyr)
|
||||||
expect_output(septic_patients %>% select(1:2) %>% freq() %>% print())
|
expect_output(septic_patients %>% select(1:2) %>% freq() %>% print())
|
||||||
|
Loading…
Reference in New Issue
Block a user