Skip to content

Instantly share code, notes, and snippets.

View zappingseb's full-sized avatar
🏠
Working from home

Sebastian Engel-Wolf zappingseb

🏠
Working from home
View GitHub Profile
<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>
@zappingseb
zappingseb / index.php
Last active February 12, 2019 05:34
Medium to r-bloggers
<?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
@zappingseb
zappingseb / tablemodule_methods.R
Last active January 13, 2019 10:22
biowarptruck tablemodule part2
# Table Methods -------------------------------------------------------------
setMethod("shinyElement",signature = "TableElement",definition = function(object){
renderDataTable(evalElement(object))
})
setMethod("pdfElement",signature = "TableElement",definition = function(object){
grid.table(evalElement(object))
})
@zappingseb
zappingseb / tablemodule.R
Last active January 13, 2019 10:03
biowarptruck tablemodule
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
@zappingseb
zappingseb / plotmodule
Created January 13, 2019 09:58
biowarptruck plot module
# 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
@zappingseb
zappingseb / pdf.R
Created January 12, 2019 20:58
biowarptruck pdf
# 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{
@zappingseb
zappingseb / render.R
Last active January 12, 2019 20:43
biowarpTruck rendering
# 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
))
})
@zappingseb
zappingseb / AnyPlot.R
Created January 9, 2019 14:08
AnyPlot-class
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)
})
@zappingseb
zappingseb / Report.R
Last active January 9, 2019 13:55
Report-class
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
@zappingseb
zappingseb / RTest_input_data.xml
Last active December 31, 2018 13:32
RTest_part2
<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>