A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
#' ## Storing R Objects in a SQLite Database | |
#' Two packages we are using. The first is the ```RSQLite``` which will be used to create and manage an in-memory SQLite database. The second is ```igraph``` which I will use to create and visualize a random network. Some of the work I do is on network simulation. I often don't know the metrics I need from a simulated network when it's created, so I want to be able to store the networks that are created so that I can go back later and analyze them. | |
library(RSQLite) | |
library(igraph) | |
#' Create a database in memory. | |
con <- dbConnect(SQLite(), ":memory:") | |
#' The table has two columns, an *id* column and a column called *graph* which is a **blob** type. This type just stores binary data. |
#!/bin/bash | |
##################################################### | |
# Name: Bash CheatSheet for Mac OSX | |
# | |
# A little overlook of the Bash basics | |
# | |
# Usage: | |
# | |
# Author: J. Le Coupanec | |
# Date: 2014/11/04 |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
# Download the data from github (click the "raw" button, save as a text file called "results.txt"). | |
# https://gist.github.com/stephenturner/806e31fce55a8b7175af | |
res <- read.table("results.txt", header=TRUE) | |
head(res) | |
# Make a basic volcano plot | |
with(res, plot(log2FoldChange, -log10(pvalue), pch=20, main="Volcano plot", xlim=c(-2.5,2))) | |
# Add colored points: red if padj<0.05, orange of log2FC>1, green if both) | |
with(subset(res, padj<.05 ), points(log2FoldChange, -log10(pvalue), pch=20, col="red")) |
#!/usr/bin/ruby | |
# Create display override file to force Mac OS X to use RGB mode for Display | |
# see http://embdev.net/topic/284710 | |
require 'base64' | |
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay` | |
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten | |
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten |
# .bashrc | |
# Source global definitions | |
if [ -f /etc/bashrc ]; then | |
. /etc/bashrc | |
fi | |
# User specific aliases and functions | |
### autocorrects cd misspellings, 'cd /sur/src/linus' >> 'cd /usr/src/linux' ### |
I recently needed a way to run unit tests on Travis for a project that uses Sun Grid Engine, Grid Map. Unfortunately, it seemed like no one had figured out how to set that up on Travis before (or simply create a single-machine installation without any user interaction). After hours of trial-and-error, I now know the secrets to making a single-machine installation of SGE that runs on Travis, and I'm sharing my script to prevent other people from going through the same frustrating experience.
To use the install_sge.sh
script below, you just need to copy all of the files in this gist to a travis
sub-directory directly under the root of your GitHub project, and add the following lines to your .travis.yml
before_install:
- travis/install_sge.sh
- export SGE_ROOT=/var/lib/gridengine
- export SGE_CELL=default
- export DRMAA_LIBRARY_PATH=/usr/lib/libdrmaa.so.1.0
def line | |
new File("test.txt").withReader { line = it.readLine() } | |
println line |
""" | |
We want to run a function asychronously and run a | |
callback function with multiple parameters when it | |
returns! | |
In this example, we are pretending we're analyzing | |
the names and ages of some people. We want to print | |
out: | |
jack 0 |