#' @export
visualize <- function(r) {
UseMethod("visualize")
}
visualize.response <- function(r) {
ct <- r[['headers']][['content-type']]
if(!grepl('html', ct)) {
stop('Not a HTML file.')
}
if(interactive()) {
dir <- tempfile()
dir.create(dir)
html_file <- file.path(dir, "index.html")
h <- httr::content(r, 'text')
enc <- stringi::stri_enc_detect(h)[[1]]$Encoding[1]
h <- iconv(h, from = 'UTF-8', to = 'ISO-8859-1')
cat(h, file = html_file)
rstudioapi::viewer(html_file)
}
}
#' Pipe operator
#'
#' See \code{\link[magrittr]{\%>\%}} for more details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.