This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################################## | |
### This script is designed to create a JSON formatted for the D3 Sankey Diagram. The JSON ### | |
### consists of nodes and links. The script can take in 2 or more categorical variables and ### | |
### and 1 numerical value variable. ### | |
################################################################################################## | |
# import libraries | |
library(reshape2) | |
library(plyr) | |
library(rjson) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import libraries | |
library(shiny) | |
########## | |
# SERVER # | |
########## | |
#generic line initiating the SERVER | |
server <- shinyServer(function(input, output) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'uri' | |
#enter URL here | |
url = 'https://www.google.com' | |
#verify URL | |
if url =~ /\A#{URI::regexp(['http', 'https'])}\z/ | |
puts “URL Verified" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup script for the Bitnam LAMP AMI on Amazon AWS | |
## This script sets up Python 2.7 and installs libraries critical to webscraping | |
apt-get update | |
sudo apt-get install python2.7-dev | |
apt-get install python-pip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!-- Credit to http://bost.ocks.org/mike/sankey/ and http://bl.ocks.org/d3noob/5028304 --> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Page Title</title> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Chord Diagram</title> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<style type="text/css"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#list all files from a folder | |
getFolderContent = function(path) { | |
pathNow = getwd() | |
setwd(path) | |
files = list.files() | |
setwd(pathNow) | |
files | |
} | |
#create helper function to paste path and file, then get info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.bar { | |
fill: steelblue; | |
} | |
.incomplete { | |
opacity: 0.5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rename a column | |
renameCol = function(df, oldName, newName) { | |
names(df)[names(df) == oldName] = newName | |
df | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df <- data.frame(id = seq(1, 500), | |
attr1 = rep(c("up", "up", "down", "down")), | |
attr2 = rep(c("left", "right", "left", "right")), | |
attr3 = rep(c("b", "a", "select", "start")), | |
attr4 = sample(c("c", "o", "n", "t", "r", "a"), 100, replace=T), | |
x = rnorm(100)) | |
dfChar = df | |
dfChar[, names(dfChar)] <- lapply(dfChar[, names(dfChar)], as.character) | |
dt = as.data.table(df) |
OlderNewer