Skip to content

Instantly share code, notes, and snippets.

Mark Heckmann markheckmann

Block or report user

Report or block markheckmann

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markheckmann
markheckmann / remove_password_excel.R
Last active Dec 25, 2019
Remove sheet's password protection in Excel
View remove_password_excel.R
# remove sheet protection in Excel
# Sample file: https://www.dropbox.com/s/4ul0kowrscyr8cz/excel_protected.xlsx?dl=0
library(stringr)
library(zip)
# file with protected sheets
file <- "data/excel_protected.xlsx"
# file name and path after removing protection
@markheckmann
markheckmann / node_barplot2.R
Last active Nov 19, 2015
A tweaked partykit::node_barplot function that adds an additional horizontal line
View node_barplot2.R
node_barplot2 <- function(obj,
col = "black",
fill = NULL,
beside = NULL,
ymax = NULL,
ylines = NULL,
widths = 1,
gap = NULL,
reverse = NULL,
id = TRUE,
@markheckmann
markheckmann / hcl_color_wheels
Last active Mar 1, 2018
Color wheels using colorspace::hcl by luminance
View hcl_color_wheels
library(colorspace)
polar2cart <- function(r, theta) # polar to cartesian coords
{
rad <- theta * pi /180
cbind(x = r*cos(rad),
y = r*sin(rad))
}
h <- seq(0, 360, len=150) # hue values
@markheckmann
markheckmann / postprocess_markdown.R
Last active Aug 29, 2015
Post-process markdown code to paste into Wordpress
View postprocess_markdown.R
change_tex_delimiters <- function(x)
{
# replace latex equation delimiters ($$) if present
eq <- which(x == "$$") # find positions of equations
if (length(eq) > 0) {
eq.begin <- eq[c(T,F)]
eq.end <- eq[c(F,T)]
for (i in eq.begin)
x[[i]] <- "$latex \\displaystyle"
for (i in eq.end)
View server.R
shinyServer(function(input, output, session) {
observe({
input$btn
session$sendCustomMessage(type = "resetFileInputHandler", "file1")
})
})
@markheckmann
markheckmann / server.R
Created Dec 31, 2013
shiny progress bar
View server.R
library(shiny)
library(shinyIncubator)
shinyServer(function(input, output, session) {
output$out2 <- renderPrint({
"output 2"
})
output$plot <- renderPlot({
@markheckmann
markheckmann / mycode.js
Created Nov 20, 2013
client/server interaction with shiny - part 3 (separate JS file)
View mycode.js
// Execute function body when the HTML document is ready
$(document).ready(function() {
// javascript code to send data to shiny server
document.getElementById("mydiv").onclick = function() {
var number = Math.random();
Shiny.onInputChange("mydata", number);
};
@markheckmann
markheckmann / server.R
Created Nov 19, 2013
client/server interaction with shiny - part 2
View server.R
library(shiny)
shinyServer( function(input, output, session) {
output$results <- renderPrint({
input$mydata
})
# observer if value of the data sent from the client changes
# if yes generate a new random color and send it back to
@markheckmann
markheckmann / server.R
Created Nov 19, 2013
client/server interaction with shiny - part 1
View server.R
library(shiny)
shinyServer( function(input, output, session) {
output$results <- renderPrint({
input$mydata
})
})
View R code test 2
### DATA PREP ###
# loading the unemployment data
unempl <- read.delim2(file="./data/data_germany_unemployment_by_
county.txt", header = TRUE, sep = "\t",
dec=",", stringsAsFactors=F)
# due to Mac OS encoding, otherwise not needed
gadm_names <- iconv(gadm$NAME_3, "ISO_8859-2", "UTF-8")
# fuzzy matching of data: quick & dirty
You can’t perform that action at this time.