Skip to content

Instantly share code, notes, and snippets.

View JohnCoene's full-sized avatar
🍰
Cake!

John Coene JohnCoene

🍰
Cake!
View GitHub Profile
@JohnCoene
JohnCoene / custom_spinner.R
Last active February 26, 2021 16:28
Waiter with a custom spinner
library(shiny)
library(waiter)
spinner <- HTML(
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve">
<path fill="#025fb6" stroke="none" class="tire" d="M96.986,49.287H100c-0.034-2.642-0.277-5.234-0.708-7.754l-2.974,0.547l-0.25-1.357l2.97-0.557
c-0.558-2.803-1.353-5.518-2.358-8.135l-2.812,1.123l-0.514-1.279l2.813-1.133c-1.128-2.69-2.479-5.264-4.033-7.695l-2.528,1.7
l-0.763-1.162l2.524-1.66c-1.646-2.417-3.496-4.678-5.527-6.768l-2.134,2.139l-0.981-0.977l2.135-2.139
c-1.855-1.807-3.857-3.477-5.981-4.98l-1.714,2.495l-1.143-0.786l1.713-2.495c-2.338-1.567-4.823-2.935-7.422-4.092L69.116,7.1
l-1.271-0.547l1.191-2.793c-2.656-1.099-5.43-1.973-8.296-2.598l-0.61,2.979l-1.357-0.278l0.615-2.979C56.566,0.3,53.7,0,50.7,0
@JohnCoene
JohnCoene / http-exercise.Rmd
Created October 6, 2020 12:58
HTTP request exercise
---
title: "Shiny HTTP response"
author: "John Coene"
date: "`r Sys.Date()`"
output: html_document
---
Start from the application we put together previously (below).
```r
@JohnCoene
JohnCoene / http_intro.R
Created October 6, 2020 12:57
Intro to HTTP requests with shiny
library(shiny)
ui <- fluidPage(
uiOutput("intro")
)
server <- function(input, output, session){
# serve the response
path <- session$registerDataObj(
@JohnCoene
JohnCoene / app.R
Created October 1, 2020 16:45
Scatter GL with shiny
library(shiny)
ui <- fluidPage(
htmlwidgets::getDependency("echarts4r"), # add dependencies
tags$script(src="https://cdn.jsdelivr.net/npm/echarts-gl/dist/echarts-gl.min.js"), # add webgl
htmltools::includeScript("scatter.js"),
div(id="chart", style="height:90%; width:100%; min-height: 400px;")
)
server <- function(input, output, session) {
@JohnCoene
JohnCoene / echarts-color-multiple.R
Last active August 26, 2020 15:23
Every echarts4r "geom" takes a `color` argument
library(shiny)
library(dplyr)
library(echarts4r)
color_it <- function(x){
switch(x,
setosa = "#5858A0",
versicolor = "#9cd156",
virginica = "#c99535"
)
@JohnCoene
JohnCoene / nav.R
Created July 15, 2020 20:35
Custom navigation
library(shiny)
ui <- navbarPage(
"example",
id = "tabs",
header = list(
tags$style("nav{display:none;}")
),
tabPanel(
"home",
@JohnCoene
JohnCoene / e_candle.R
Created June 29, 2020 06:39
Candlestick color
library(echarts4r)
library(quantmod)
getSymbols("GS") #Goldman Sachs
GS <- as.data.frame(GS)
GS$date <- row.names(GS)
# https://echarts.apache.org/en/option.html#series-candlestick.itemStyle.color
GS %>%
e_charts(date) %>%
@JohnCoene
JohnCoene / test.R
Last active June 20, 2020 16:03
erer
library(shiny)
ui <- fluidPage(
gioOutput("globe"),
verbatimTextOutput("selected")
)
server <- function(input, output, session) {
output$globe <- renderGio({
@JohnCoene
JohnCoene / echarts4r_factor.R
Last active June 17, 2020 08:45
Echarts4r factor order
library(echarts4r)
df <- data.frame(
x = rev(rep(letters, 2)),
y = runif(52),
group = factor(c(rep("C", 26), rep("A", 26)), levels = c("A", "C"))
)
df %>%
dplyr::arrange(group) %>%
@JohnCoene
JohnCoene / shinydash-waiter.R
Last active May 21, 2020 11:29
shinydashboard overlay waiter on tab content
## app.R ##
library(shiny)
library(waiter)
library(shinydashboard)
# add JavaScript to add an id to the <section> tag so we can overlay waiter on top of it
add_id_to_section <- "
$( document ).ready(function() {
var section = document.getElementsByClassName('content');
section[0].setAttribute('id', 'waiter-content');