Skip to content

Instantly share code, notes, and snippets.

View geneorama's full-sized avatar

Gene Leynes geneorama

View GitHub Profile
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 August 29, 2015 14:22
Reshaping with data.table
## 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 September 23, 2014 17:08
leaflet_fullexample
<!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 August 29, 2015 14:06
Leaflet_example_3
// 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" />
@geneorama
geneorama / index.html
Last active August 29, 2015 14:06
LeafletExample
// Gene Leynes 2014-09-23
// 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>
// create a map in the "map" div, set the view to a given place and zoom
@geneorama
geneorama / gist:4998308
Created February 20, 2013 19:14
Data.table column conversion question

I want to update a group of columns programmatically. This is simple using data.frame, but in data.table this requires a confusing combination of substitute, as.symbol, and eval.

Am I doing this right?

Simple example:

## GENERATE DATA
library(data.table)
set.seed(1)

dt <- data.table(

#include<iostream>
#include<cmath>
#include<stdlib.h>
using namespace std;
int main() {
int n,i;
int is_prime = true;
cout << "Enter a number and press ENTER: ";