Skip to content

Instantly share code, notes, and snippets.

---
title: "Standard Non-Standard Evaluation"
output: html_notebook
---
```{r}
library(tidyverse)
```
@tmastny
tmastny / shiny-shifted-oma.R
Created June 21, 2018 23:18
Shifted Coordinate Values in Shiny App due to outer margins
library(shiny)
ui <- basicPage(
HTML("oma"),
numericInput("oma_one", "bottom", value = 0),
numericInput("oma_two", "left", value = 0),
numericInput("oma_three", "top", value = 0),
numericInput("oma_four", "right", value = 0),
plotOutput("plot1",
click = "plot_click",
dblclick = "plot_dblclick",
@tmastny
tmastny / line-profile-report.Rmd
Last active July 9, 2018 20:21
Profiling Line Plots
---
title: "Line Plot"
author: "Tim Mastny"
date: "7/9/2018"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@tmastny
tmastny / haml.R
Last active August 2, 2018 22:46
library(rlang)
# from adv-r
partition_nameness <- function(lst) {
is_named <- names(lst) != ""
list(
named = lst[is_named],
unnamed = lst[!is_named]
)
}
# curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
source ~/.git-prompt.sh
# save lots of history
export HISTFILESIZE=10000
.First <- function() {
# Sys.setenv(TZ = "America/Chicago")
options(
warnPartialMatchArgs = TRUE,
warnPartialMatchAttr = TRUE,
warnPartialMatchDollar = TRUE,
repos = c(CRAN = "https://cloud.r-project.org"),
servr.daemon = TRUE,
blogdown.author = "Tim Mastny",
usethis.full_name = "Timothy Mastny",
# .R/Makevars
# debug unoptimized build
# CFLAGS += -g -O0 -Wall
# CXXFLAGS += -g -O0 -Wall
# CXX11FLAGS += -g -O0 -Wall
MAKE = make -j5
@tmastny
tmastny / R
Created August 21, 2018 00:42
put in bin for nice R executable
#!/bin/bash
RLINK='/Library/Frameworks/R.framework/Resources/bin/R'
if [ -z "$*" ]
then
# /usr/local/bin/R --no-save --no-restore-data --quiet
$RLINK --no-save --no-restore-data --quiet
else
# /usr/local/bin/R "$@"
$RLINK "$@"
fi
@tmastny
tmastny / rstudio
Created August 21, 2018 00:43
put in bin to launch rstudio app (can even use to open files)
#!/bin/bash
open -a "RStudio" "$@"
@tmastny
tmastny / meaning-chains.R
Created August 30, 2018 18:53
Meaning chains with word embeddings
# http://sappingattention.blogspot.com/2018/06/meaning-chains-with-word-embeddings.html
cpath = function(matrix, w1, w2, blacklist = c()) {
p1 = matrix[[w1]]
p2 = matrix[[w2]]
base_similarity = cosineSimilarity(p1, p2)
pairsims = matrix %*% t(rbind(p1, p2))
# Words closer to *either* candidate than the other word. These might be used eventually; mostly to save on computation in later steps.
decentsims = pairsims[apply(pairsims, 1, max) >= base_similarity[1],]