Skip to content

Instantly share code, notes, and snippets.

View markheckmann's full-sized avatar
🦮

Mark Heckmann markheckmann

🦮
View GitHub Profile
@markheckmann
markheckmann / officer_issue_681_examples.R
Last active October 8, 2025 14:18
WIP: pass dots to ph_with method. Working version for all methods.
### Prepare ----------------------------------------
library(devtools)
dev_mode(TRUE)
devtools::install_github("markheckmann/officer", "aec62c3")
library(officer)
library(ggplot2)
@markheckmann
markheckmann / remove_password_excel.R
Last active February 4, 2022 05:27
Remove sheet's password protection in Excel
# 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 November 19, 2015 16:34
A tweaked partykit::node_barplot function that adds an additional horizontal line
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 March 1, 2018 21:16
Color wheels using colorspace::hcl by luminance
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 August 29, 2015 14:11
Post-process markdown code to paste into Wordpress
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)
shinyServer(function(input, output, session) {
observe({
input$btn
session$sendCustomMessage(type = "resetFileInputHandler", "file1")
})
})
@markheckmann
markheckmann / server.R
Created December 31, 2013 01:44
shiny progress bar
library(shiny)
library(shinyIncubator)
shinyServer(function(input, output, session) {
output$out2 <- renderPrint({
"output 2"
})
output$plot <- renderPlot({
@markheckmann
markheckmann / mycode.js
Created November 20, 2013 13:35
client/server interaction with shiny - part 3 (separate JS file)
// 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 November 19, 2013 23:26
client/server interaction with shiny - part 2
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 November 19, 2013 23:23
client/server interaction with shiny - part 1
library(shiny)
shinyServer( function(input, output, session) {
output$results <- renderPrint({
input$mydata
})
})