suppressPackageStartupMessages(require(quantmod))
context("Emit")
#emit <- function(p,
# tag = "uknnown",
# path = "plots/",
# prefix = "sc_",
# suffix = ".png",
# show_warnings = FALSE,
# recursive = TRUE,
# width = 1024,
# height = 768) {
load_data <- function() {
h <- new.env()
load("testdata/history.RData",envir=h)
return(get("history",envir=h))
}
test_that("accepts defaults", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
g <- plot_model_stat(Ad(XLE),test_title)
e <- emit(g)
expect_true(names(e) %in% c("pdf","RStudioGD"))
})
test_that("accepts prefix", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
g <- plot_model_stat(Ad(XLE),test_title)
e <- emit(g,prefix="test")
expect_true(names(e) %in% c("pdf","RStudioGD"))
})
test_that("accepts dimensions", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
g <- plot_model_stat(Ad(XLE),test_title)
e <- emit(g,width=60,height=40)
expect_true(names(e) %in% c("pdf","RStudioGD"))
})
test_that("prints without grob", {
h <- load_data()
XLE <- get("XLE",envir=h)
test_title <- "XLE Adjusted"
expect_output( emit(as.data.frame(head(Cl(XLE)))), "XLE")
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.