Skip to content

Instantly share code, notes, and snippets.

View ClintWeathers's full-sized avatar

Clint Weathers ClintWeathers

  • Target
  • Minneapolis, MN
View GitHub Profile
# shortform git commands
alias g='git'
# Get a list of all TODO/FIXME tasks left to be done in your project
alias tasks='grep --exclude-dir=.git -rEI "TODO|FIXME" . 2>/dev/null'
# edit your gitignore from anywhere in your repo
vim $(git rev-parse --show-toplevel)/.gitignore
# simple single-lined git log
@ClintWeathers
ClintWeathers / index.html
Created December 20, 2014 04:25
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
http://www.urbpoidzbi.com
http://www.muqvfhccdi.com
http://www.fkvewqboqk.com
http://www.ahyeiigjrf.com
http://www.bmrvmrppne.com
http://www.hebadssdwf.com
http://www.ppklogqhbc.com
http://www.xtzxvxldpe.com
http://www.jgelngzvni.com
http://www.bvwedfcbfa.com
@ClintWeathers
ClintWeathers / custom.css
Created June 5, 2015 23:13
1000px rendering for rmarkdown
.main-container {
max-width: 1000px !important;
}
@ClintWeathers
ClintWeathers / gist:60c1333ef46220ed355b
Created August 18, 2015 13:27
Question Re Piping Inside A Function
It's not uncommon where I'm working to get some dataset with a needlessly longass name and needlessly longass field names.
Unfortunately, they want the field names and dataset names left as is, in situ.
Is there something like %>% for single-line stuff that would do this:
Instead of...
omgthisdatasetnameissolong$whythehelldidtheynamethisfieldlikethis <- as.character(omgthisdatasetnameissolong$whythehelldidtheynamethisfieldlikethis)
maybe this...
@ClintWeathers
ClintWeathers / paramed_query.R
Last active November 4, 2015 21:51
paramaterized query using ldply.R
library(RODBC)
library(RODBCext)
dbconn <- odbcConnect(dsn = "dbname", uid = "me", pwd = "password")
query <- "select * from table where blah = 'blahblahblah' and blah2 = ?"
results <- function(x){
sqlExecute(dbconn, query, x)
sqlGetResults(dbconn)
}
@ClintWeathers
ClintWeathers / rmdweirdness.Rmd
Created November 19, 2015 21:50
Weirdness in RMarkdown/Shiny
---
title: "Testing1"
author: "JCW"
date: "November 19, 2015"
output:
html_document:
highlight: haddock
theme: cosmo
---
@ClintWeathers
ClintWeathers / dplyrstuff.R
Last active December 24, 2017 03:05
Trying to make a new dataframe using Dplyr
### Trying to create new dataframes from dplyr 0.4.3 functions using R 3.2.2.
#Very Simple Example:
paste("cars_with", 6, "cylinders", sep = "_") <- filter(mtcars, cyl == 6)
#What I want there is a dataframe named "cars_with_6_cylinders" that has the results of this:
filter(mtcars, cyl == 6)
#But instead, what I get is this:
@ClintWeathers
ClintWeathers / ggvisdensitycrash.R
Created November 21, 2015 21:02
fill + opacity in layer_densities() causes crash in ggvis
# Started from here, an example from Hadley Wickham in the google groups https://groups.google.com/forum/#!topic/ggvis/AJZCdjFcNaE.
# Using R 3.2.1 x86_64, ggvis 0.4.2.
cocaine %>%
ggvis( ~ potency, ~ price) %>%
filter(state %in% eval(input_checkboxgroup(c("IA", "MN", "WI"),
selected = "WI"))) %>%
layer_points(fill = ~ state, size := 50, opacity := 0.5)
# This works fine and evals the way one would expect.
@ClintWeathers
ClintWeathers / readr_crash.txt
Created December 9, 2015 21:23
readr crash during read_csv()
> may_2015 <-
+ read_csv(
+ "Z:/data_CSVs/thingsandstuff_files/may2015.csv"
+ )
Assertion failed!
Program: C:\Users\ahm0\Documents\RStudio\bin\rsession.exe
File: d:/RCompile/CRANpkg/lib/3.2/BH/include/boost/spirit/home/support/detail/pow10.hpp, Line 87
Expression: dim < sizeof(exponents)/sizeof(double)