-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
123 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
|
||
# Test vectors: | ||
x1 <- c("a", "a", "a", "b", "b", "c", rep(NA, times = 5)) | ||
x2 <- c(1, 1, 2, 3, rep(NA, times = 6)) | ||
|
||
|
||
test_that("`frequency_grid_df()` works with `x1`", { | ||
expect_equal(frequency_grid_df(x1), structure(list( | ||
x = c("a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"), | ||
freq = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), | ||
is_missing = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), | ||
can_be_filled = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE), | ||
is_supermodal = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE) | ||
), class = "data.frame", row.names = c(NA, -12L))) | ||
}) | ||
|
||
test_that("`frequency_grid_df()` works with `x2`", { | ||
expect_equal(frequency_grid_df(x2), structure(list( | ||
x = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3), | ||
freq = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), | ||
is_missing = c(FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), | ||
can_be_filled = c(FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE), | ||
is_supermodal = c(FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE) | ||
), class = "data.frame", row.names = c(NA, -12L))) | ||
}) | ||
|
||
# | ||
# # Test vectors: | ||
# x1 <- c("a", "a", "a", "b", "b", "c", rep(NA, times = 5)) | ||
# x2 <- c(1, 1, 2, 3, rep(NA, times = 6)) | ||
# | ||
# | ||
# test_that("`frequency_grid_df()` works with `x1`", { | ||
# expect_equal(frequency_grid_df(x1), structure(list( | ||
# x = c("a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"), | ||
# freq = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), | ||
# is_missing = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), | ||
# can_be_filled = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE), | ||
# is_supermodal = c(FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE) | ||
# ), class = "data.frame", row.names = c(NA, -12L))) | ||
# }) | ||
# | ||
# test_that("`frequency_grid_df()` works with `x2`", { | ||
# expect_equal(frequency_grid_df(x2), structure(list( | ||
# x = c(1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3), | ||
# freq = c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), | ||
# is_missing = c(FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE), | ||
# can_be_filled = c(FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE), | ||
# is_supermodal = c(FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE) | ||
# ), class = "data.frame", row.names = c(NA, -12L))) | ||
# }) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: "Frequency grids" | ||
output: rmarkdown::html_vignette | ||
vignette: > | ||
%\VignetteIndexEntry{Frequency grids} | ||
%\VignetteEngine{knitr::rmarkdown} | ||
%\VignetteEncoding{UTF-8} | ||
--- | ||
|
||
```{r, include = FALSE} | ||
knitr::opts_chunk$set( | ||
collapse = TRUE, | ||
comment = "#>" | ||
) | ||
``` | ||
|
||
```{r setup} | ||
library(moder) | ||
``` | ||
|
||
NOTE: This is not (yet) a proper documentation vignette. | ||
|
||
TODO: Either elaborate this into a real vignette or turn it into a (final) section of the metadata vignette! | ||
|
||
The output of moder's metadata functions can be puzzling. Why do they return `NA` for this vector but not for that one? Frequency grids will help you understand. | ||
|
||
A frequency grid is a special kind of histogram. It is meant to depict possible ways in which the true values behind missing values may be distributed. As such, it illustrates the rationale of metadata functions such as `mode_count_range()`. | ||
|
||
```{r} | ||
# x <- c("a", "a", "a", "b", "b", "c", NA, NA, NA, NA, NA) | ||
# frequency_grid_plot(x) | ||
``` | ||
|