forked from tidyverse/ggplot2
-
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.
Add test file with a doppelganger-test
- Loading branch information
Thomas Knecht
authored and
Thomas Knecht
committed
Sep 17, 2019
1 parent
a681f59
commit e2c1fb6
Showing
1 changed file
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
context("position_nudgestack") | ||
|
||
test_that("position_nudgestack draws correctly", { | ||
ESM <- data_frame( | ||
DAX = EuStockMarkets[colnames(EuStockMarkets) == "DAX"], | ||
SMI = EuStockMarkets[colnames(EuStockMarkets) == "SMI"], | ||
CAC = EuStockMarkets[colnames(EuStockMarkets) == "CAC"], | ||
FTSE = EuStockMarkets[colnames(EuStockMarkets) == "FTSE"], | ||
date = as.Date(paste(1, zoo::as.yearmon(time(EuStockMarkets))), | ||
format = "%d %b %Y" | ||
) | ||
) | ||
|
||
ESM_prep <- ESM %>% | ||
tidyr::gather(key = key, value = value, -date) %>% | ||
group_by(date, key) %>% | ||
summarize(value = mean(value)) %>% | ||
filter(date >= "1995-01-01" & date < "1998-01-01") | ||
|
||
stock_marked <- ggplot(data = ESM_prep, mapping = aes(x = date, y = value, fill = key)) + | ||
geom_col(position = position_nudgestack(x = 15)) | ||
|
||
expect_doppelganger( | ||
"nudgestack EuStockMarkets data", | ||
stock_marked | ||
) | ||
}) |