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
<item> | |
<title> | |
<![CDATA[ | |
That’s a nice way to describe rendering in the browser. | |
]]> | |
</title> | |
<link> | |
https://medium.com/@zappingseb/thats-a-nice-way-to-describe-rendering-in-the-browser-e3550194ae08?source=rss-dbc9f652035a------2 | |
</link> | |
<guid isPermaLink="false">https://medium.com/p/e3550194ae08</guid> |
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
<?php | |
header('Content-Type: text/xml'); | |
$xml = new DOMDocument; | |
$url = "https://medium.com/feed/@zappingseb"; | |
$xml->load($url); | |
$book = $xml->documentElement; | |
// we retrieve the chapter and remove it from the book |
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
# Table Methods ------------------------------------------------------------- | |
setMethod("shinyElement",signature = "TableElement",definition = function(object){ | |
renderDataTable(evalElement(object)) | |
}) | |
setMethod("pdfElement",signature = "TableElement",definition = function(object){ | |
grid.table(evalElement(object)) | |
}) |
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
setClass("TableElement", representation(obs="numeric"), contains = "AnyPlot") | |
setClass("TableReport",contains = "Report") | |
TableElement <- function(obs=100){ | |
new("TableElement", | |
plot_element = expr(data.frame(x=sample(x=!!obs,size=5))) | |
) | |
} | |
#' Constructor for a TableReport |
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
# Define Classes to use inside the apps ------------------------------------------------------------ | |
setClass("HistPlot", representation(color="character",obs="numeric"), contains = "AnyPlot") | |
setClass("ScatterPlot", representation(obs="numeric"), contains = "AnyPlot") | |
setClass("PlotReport",contains = "Report") | |
HistPlot <- function(color="darkgrey",obs=100){ | |
new("HistPlot", | |
plot_element = expr(hist(rnorm(!!obs), col = !!color, border = 'white')), | |
color = color, | |
obs = obs |
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
# Observe PDF button and create PDF | |
observeEvent(input$"renderPDF",{ | |
# Create PDF | |
report <- pdfElement(report_obj()) | |
# If the PDF was successfully rendered update text message | |
if(report@rendered){ | |
output$renderedPDF <- renderText("PDF rendered") | |
}else{ |
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
# Create a reactive to create the Report object due to | |
# the chosen module | |
report_obj <- reactive({ | |
module <- unlist(lapply(configuration,function(x)x$name==input$modules)) | |
if(!any(module))module <- c(TRUE,FALSE) | |
do.call(configuration[[which(module)]][["class"]], | |
args=list( | |
obs = input$obs | |
)) | |
}) |
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
setClass("AnyPlot", representation(plot_element = "call")) | |
# constructor | |
AnyPlot <- function(plot_element=expr(plot(1,1))){ | |
new("AnyPlot", plot_element = plot_element) | |
} | |
setMethod("evalElement",signature = "AnyPlot",definition = function(object){ | |
eval(object@plot_element) | |
}) |
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
setClass("Report",representation(plots="list", filename="character", obs="numeric", rendered="logical")) | |
setMethod("pdfElement",signature = "Report",definition = function(object){ | |
tryCatch({ | |
pdf(object@filename) | |
lapply(object@plots,function(x){ | |
pdfElement(x) | |
}) | |
dev.off() | |
object@rendered <- TRUE |
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
<input-data> | |
<data.frame name="test01"> | |
<col-defs> | |
<coldef name="x" type="numeric" /><coldef name="y" type="numeric" /> | |
</col-defs> | |
<row> | |
<cell>1</cell><cell>2</cell> | |
</row> | |
<row> | |
<cell>1</cell><cell>2</cell> |