freq: support for table

This commit is contained in:
dr. M.S. (Matthijs) Berends committed 2018-07-09 14:02:58 +02:00
1 parent 18c91786bf
commit fc30d3fb13
9 files changed
+198 -92

No files matched your search

+14 -1
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())
})