Skip to content

Instantly share code, notes, and snippets.

Gene Leynes geneorama

View GitHub Profile
@geneorama
geneorama / readme.md
Last active Dec 6, 2018
msysgit readme
View readme.md

Copy readme from https://github.com/msysgit/msysgit

I copied this in case they change it or the package goes away. This document describes the componentes of msysgit, which is part of git bash for windows. It explains the difference between MSys and MinGW, and has a link to a very useful wiki (https://github.com/msysgit/msysgit/wiki) with instructions on how to report bugs etc.


README.md for msysgit/msysgit

Please note!

View gist:14b947e5dbe18caa620dd65bacdc170f
rm(list=ls())
library(data.table)
txt <- fread("~/Downloads/iGrill Mini-5839 - Probe - 32418, 112903 AM.csv")
setnames(txt, 'Temperature (°F)', 'temperature')
setnames(txt, 'Date & Time', 'timestamp')
txt[ , timestamp := as.POSIXct(strptime(timestamp, "%m/%d/%y, %I:%M:%S %p"))]
txt[temperature == "--", temperature:=NA]
txt
@geneorama
geneorama / ls.socrata example.md
Last active Dec 6, 2018
flattening `ls.socrata`
View ls.socrata example.md

Flatten return values Socrata's data view

You can get the list of data sets in a Socrata domain with the data.json route, for example; "http://soda.demo.socrata.com/data.json".

However there are some very nested objects that are inconvenient for R. This is just an example of how to flatten specifically the data.json return value from Socrata.

This is not tested. This was a demo in conjunction with work on ls.socrata in the package https://github.com/Chicago/RSocrata/

@geneorama
geneorama / glmnet_girdsearch.R
Created Nov 2, 2016
Heap your criticisms here
View glmnet_girdsearch.R
grid_glmnet <- expand.grid(alpha = c(0, .2, .4, .6, .8, 1),
# lambda = seq(.01, .2, length = 40))
#lambda = rev(exp(seq(log(.00001), log(200), length=10)))
lambda = rev(exp(seq(log(.00001), log(20), length=20))))
results_glmnet <- list()
# g <- unique(dat$grp)[1]
# i <- 1
for(i in 1:nrow(grid_glmnet)){
print(i)
@geneorama
geneorama / label_encoding_beginning
Last active Feb 1, 2018
Example of how to encode data frame with string / factor levels into numeric factor levels, and store the encoding.
View label_encoding_beginning
##
## gene leynes 2016-10-28
##
## Label encoder based on
## http://stackoverflow.com/questions/38620424/label-encoder-functionality-in-r
##
encoding_matrix <- function(df, plug_missing = TRUE, missing_string = "MISSING"){
df <- as.data.frame(df)
cols <- which(sapply(df, is.character) | sapply(df, is.factor))
@geneorama
geneorama / index.html
Last active Oct 10, 2016
WNV_Map_with_counts
View index.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
View randomForest_factor_extrapolation.R
rm(list=ls())
library(randomForest)
################################################################################
## EXAMPLE 1 (ver_1)
## Two data frames are created (test and train)
## They have their own independent factor levels, and some of the levels in
## `test_ver1` do not appear in `train_ver1`
##
@geneorama
geneorama / gist:7d7ec0a1884f9b4defe2
Last active Aug 29, 2015
Reshaping with data.table
View gist:7d7ec0a1884f9b4defe2
## Using example from Arun's presentation:
## https://twitter.com/MattDowle/status/605881443491774464
##------------------------------------------------------------------------------
## INITIALIZE
## Load library, copy melt out of data.table, and create data example
##------------------------------------------------------------------------------
library(data.table) ## v1.9.4
melt <- data.table:::melt.data.table ## Something I usually do, just in case
@geneorama
geneorama / index.html
Created Sep 23, 2014
leaflet_fullexample
View index.html
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Quick Start Guide Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../dist/leaflet.css" />
@geneorama
geneorama / index.html
Last active Aug 29, 2015
Leaflet_example_3
View index.html
// Gene Leynes 2014-09-23 SOME EDITS
// Example taken (borrowed) from http://leafletjs.com/
// I'm using this example to test http://bl.ocks.org/
// (this should now be index.html)
<!DOCTYPE html>
<meta charset="utf-8">
<style>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
You can’t perform that action at this time.