Skip to content

Instantly share code, notes, and snippets.

Intro to R

Introduction

R is a good tool in your toolbox to manipulate and visualize local data. Even if you can only make bar charts and line charts, it can be very useful compared to only display the data in text. It also has a nice IDE (RStudio).

When you look for answer in stackoverflow about R, you might have many wtf moment. There are many absurd-hacky answers that people gladly offer. This is often frustating. I think this paragraph resembles a lot with R situation:

Just for reference, 80% of awful Perl "code" in my $work falls under this - it was written by financial analysts who are smart enough to pick up a Perl book and some earlier scripts, clone off a script that does what business need is, and don't have CS/programming background to worry about how readable/maintainable their code was. - from stackoverflow

This short guide shows a minimal way to get something done in R.

package main
import (
"fmt"
"io"
"os"
"testing"
)
var tests = []struct {
@irvifa
irvifa / custom-open-file.py
Created February 7, 2018 05:12
datadog custom metrics
import resource
import subprocess
import os
import pwd
import time
from datadog import statsd, initialize
class OpenFileCheck(object):
@irvifa
irvifa / fourSum.cpp
Last active June 17, 2017 03:49
mock myself
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
class Solution {
public:
vector<vi> fourSum(vi &v, int n) {
sort(v.begin(),v.end());
set<vi> s;

Addons

It'll be created as the part of kube-system namespace, so basically just install the addons using this command for testing purpose:

cd kubernetes/cluster/addons/fluent-elasticsearch
kubectl create -f es-controller.yaml
kubectl create -f es-service.yaml
kubectl create -f kibana-controller.yaml
kubectl create -f kibana-service.yaml
#include<bits/stdc++.h>
using namespace std;
#define MAXV 1300
#define MAXF 60
int T, r, c, i, j, flow,H,W;
char m[MAXF][MAXF];
bool vis[MAXV];
int res[MAXV][MAXV], p[MAXV];
@irvifa
irvifa / curl.py
Last active April 24, 2016 00:15
fishbit2016
import requests
data = {"port":"merak", "depart":"24/04/2016-17:30", "arrive":"24/04/2016-18:30", "ship_id":1, "crew_id":1, "fish_id":"kakap"}
response = requests.post('http://localhost:5000/api/v01/tap/post', json=data)
print response.json
@irvifa
irvifa / cleanup.sh
Created February 16, 2016 17:54
misc-bash
#!/bin/bash
LOG_DIR=/var/log
ROOT_UID=0
LINES=50
E_XCD=86
E_NOTROOT=87
MESSAGES=messages
TMP=mesg.tmp
@irvifa
irvifa / eulerian-path.prolog
Created February 1, 2016 06:37
solver with prolog
connected(a,b).
connected(b,c).
connected(c,a).
connected(a,e).
connected(e,c).
connected(c,d).
connected(d,e).
connected(e,b).
eulerianpath(Edges, Res) :-
class Node {
public:
int data;
Node *next;
Node(int d){
data=d;
next=NULL;
}
};