Skip to content

Instantly share code, notes, and snippets.

View byzheng's full-sized avatar

Bangyou Zheng byzheng

View GitHub Profile
@byzheng
byzheng / app.R
Created December 3, 2016 20:55
test shiny for draw plugin
library(leaflet.extras)
lat <- c(1, 2, 2, 1)
lng <- c(1, 1, 2, 2)
library(shiny)
library(leaflet)
ui <- fluidPage(
leafletOutput("mymap"),
@byzheng
byzheng / app.R
Created March 10, 2016 15:37
shiny app for drag event using L.Path.Drag. Need to install this fork: https://github.com/byzheng/leaflet/
library(leaflet)
library(shiny)
ui <- fluidPage(
leafletOutput('map'),
verbatimTextOutput('summary')
)
server <- function(input, output, session) {
@byzheng
byzheng / leafletBug.R
Last active March 8, 2016 22:47 — forked from tiernanmartin/leafletBug.R
An example illustrating a possible bug in the Leaflet package
library(shiny)
library(shinydashboard)
library(leaflet)
header <- dashboardHeader(
title = "Example",
titleWidth = "600px"
)
sidebar <- dashboardSidebar(width = "600px")
@byzheng
byzheng / leaflet-shinydashboard
Created February 26, 2016 13:24
leaflet and shinydashboard
library(leaflet)
library(shiny)
library(shinydashboard)
# header board
header <- dashboardHeader(
title = 'Pheno-Copter'
# task list for status of data processing
, dropdownMenuOutput('task_menu'))
@byzheng
byzheng / gist:83fd3fcff9e3614e8b82
Last active February 26, 2016 05:15
leafletProxy
library(shiny)
library(leaflet)
library(RColorBrewer)
ns_map <- function(id) {
ns <- NS(id)
tagList(
leafletOutput(ns("map"), width = "100%", height = "100%"),
absolutePanel(top = 10, right = 10,
sliderInput(ns("range"), "Magnitudes", min(quakes$mag), max(quakes$mag),
value = range(quakes$mag), step = 0.1
@byzheng
byzheng / app1.R
Last active February 26, 2016 12:35
test leaflet with dashboard: app1.r is working, but app2.R gives an error in console (Couldn't find map with id map)
library(shiny)
library(shinydashboard)
# header board
header <- dashboardHeader(
title = 'Pheno-Copter'
# task list for status of data processing
, dropdownMenuOutput('task_menu'))
# Side bar board
sidebar <- dashboardSidebar(
@byzheng
byzheng / server.R
Last active February 23, 2016 23:23
A shiny app to add a hyperlink and send data back to server.
library(shiny)
shinyServer( function(input, output, session) {
output$results <- renderPrint({
input$mydata
})
})
@byzheng
byzheng / xlsxToR.r
Last active March 20, 2019 06:54 — forked from schaunwheeler/xlsxToR.r
Thanks @schaunwheeler codes to read xlsx files. I had remove all dependence and parse the xml files with text regular expression. It will be much faster to read large xlsx files.
#' Read xlsx files
#'
#' @param file The path to xlsx file
#' @param keep_sheets A vector of sheet name
#' @param header Whether include the head in the sheet
#' @param empty_row Whether to remove the empty rows
#' @export
xlsxToR <- function(file, keep_sheets = NULL, header = TRUE, empty_row = TRUE)
{
suppressWarnings(file.remove(tempdir()))