context("Candelstick plot")
load_data <- function() {
h <- new.env()
load("testdata/history.RData",envir=h)
return(get("history",envir=h))
}
test_that("requires clean columns",{
h <- load_data()
XLE <- get("XLE",envir=h)
expect_error(gg_candles(get("XLE")))
})
test_that("accepts defaults", {
h <- load_data()
XLE <- get("XLE",envir=h)
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_candles(XLE)
expect_equal(length(g),10)
expect_equal(ncol(g$data),9)
expect_equal(length(g$layers),3)
expect_equal(length(g$mapping),1)
expect_equal(length(g$theme),57)
})
test_that("accepts title", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
colnames(XLE) <- gsub("XLE.","",colnames(XLE))
g <- gg_candles(XLE,title_param=test_title)
expect_equal(length(g),10)
expect_equal(ncol(g$data),9)
expect_equal(length(g$layers),3)
expect_equal(length(g$mapping),1)
expect_equal(length(g$theme),57)
expect_equal(g$labels$title,test_title)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.