Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use same density estimation code in stat_density and stat_ydensity.
Fixes #972
- Loading branch information
Showing
6 changed files
with
88 additions
and
70 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
context("stat_density") # and stat_ydensity | ||
|
||
test_that("compute_density succeeds when variance is zero", { | ||
dens <- compute_density(rep(0, 10), NULL, from = 0.5, to = 0.5) | ||
expect_equal(dens$n, rep(10, 512)) | ||
}) | ||
|
||
test_that("compute_density returns useful df when <3 values", { | ||
dens <- compute_density(c(1, 2), NULL, from = 0, to = 0) | ||
|
||
expect_equal(nrow(dens), 2) | ||
expect_equal(names(dens), c("x", "density", "scaled", "count", "n")) | ||
}) |
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