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

freq: support for table

This commit is contained in:
2018-07-09 14:02:58 +02:00
parent 18c91786bf
commit fc30d3fb13
9 changed files with 199 additions and 93 deletions

View File

@ -9,12 +9,16 @@ test_that("frequency table works", {
expect_equal(nrow(freq(septic_patients$date)),
length(unique(septic_patients$date)))
# int
# character
expect_output(print(freq(septic_patients$bactid)))
# integer
expect_output(print(freq(septic_patients$age)))
# date
expect_output(print(freq(septic_patients$date)))
# factor
expect_output(print(freq(septic_patients$hospital_id)))
# table
expect_output(print(freq(table(septic_patients$sex, septic_patients$age))))
library(dplyr)
expect_output(septic_patients %>% select(1:2) %>% freq() %>% print())
@ -53,5 +57,14 @@ test_that("frequency table works", {
plot(freq(septic_patients, age))
hist(freq(septic_patients, age))
# check vector
expect_identical(septic_patients %>%
freq(age) %>%
as.vector() %>%
sort(),
septic_patients %>%
pull(age) %>%
sort())
})