This file contains hidden or 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
#Load Data | |
#Make sure months stay ordered - first time I ever wanted a factor! | |
#Label x-axis with every fifth label...need to use character(0) in base graphics, not " "? | |
visits_visitors <- read.csv("visits_visitors.csv") | |
visits_visitors$Month <- factor(visits_visitors$Month, levels = visits_visitors$Month, ordered = TRUE) | |
visits_visitors$Month_ <- ifelse(as.numeric(row.names(visits_visitors)) %% 5 == 0, as.character(visits_visitors$Month), character(0)) | |
#Set up plot space for plot & add horizontal lines | |
barplot(visits_visitors$Views, ylim = c(0,10000), las=1, border = NA, col.axis = "darkgray", tick = FALSE) | |
abline(h=seq(2000,10000, 2000), col='lightgray') |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
#Circles | |
eo = make_euler_object(labels, data, EulerSpec()) # circles, for now | |
(minf,minx,ret) = optimize(eo, random_state(eo), ftol=-1, xtol=0.0025, maxtime=120, pop=1000) | |
println("got $minf at $minx (returned $ret)") | |
render("/home/rzwitch/Desktop/kd.svg", eo, minx) |
This file contains hidden or 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
# Rectangles | |
eo = make_euler_object(labels, data, [EulerSpec(:rectangle), EulerSpec(:rectangle, [.5, .5, .4], [0, 0, 0]), | |
EulerSpec(:rectangle)], | |
sizesum=.3) | |
(minf,minx,ret) = optimize_iteratively(eo, random_state(eo), ftol=-1, xtol=0.0025, maxtime=5, pop=100) | |
println("phase 1: got $minf at $minx (returned $ret)") | |
(minf,minx,ret) = optimize(eo, minx, ftol=-1, xtol=0.001, maxtime=30, pop=100) | |
println("phase 2: got $minf at $minx (returned $ret)") |
This file contains hidden or 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
library("RSiteCatalyst") | |
library("d3Network") | |
#### Authentication | |
SCAuth("username", "secret") | |
#### Get Pathing data using ::anything:: wildcards | |
# Results are limited by the API to 50000 | |
pathpattern <- c("::anything::", "::anything::") |
This file contains hidden or 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
#Optional step: Cleaning my pagename URLs to remove to domain for graph clarity | |
queue_pathing_pages$step.1 <- sub("http://randyzwitch.com/","", | |
queue_pathing_pages$step.1, ignore.case = TRUE) | |
queue_pathing_pages$step.2 <- sub("http://randyzwitch.com/","", | |
queue_pathing_pages$step.2, ignore.case = TRUE) | |
#### Remove Enter and Exit site values | |
#This information is important for analysis, but not related to website structure | |
graph_links <- subset(queue_pathing_pages, step.1 != "Entered Site" & step.2 != "Exited Site") |
This file contains hidden or 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
#### Second pass: thin the spaghetti blob! | |
#Require path to happen more than some number of times (count > x) | |
#What constitutes "low volume" will depend on your level of traffic | |
simpleoutput2 = "C:/Users/rzwitc200/Desktop/simpleoutput2.html" | |
d3SimpleNetwork(subset(graph_links, count > 5), Source = "step.1", Target = "step.2", height = 600, | |
width = 750, fontsize = 12, linkDistance = 50, charge = -100, | |
linkColour = "#666", nodeColour = "#3182bd", | |
nodeClickColour = "#E34A33", textColour = "#3182bd", opacity = 0.6, | |
standAlone = TRUE, file = simpleoutput2) |
This file contains hidden or 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
#### Force directed network | |
#Limit to more than 5 occurence like in simple network | |
fd_graph_links <- subset(graph_links, count > 5) | |
#Get unique values of page name to create nodes df | |
#Create an index value, starting at 0 | |
fd_nodes <- as.data.frame(unique(c(fd_graph_links$step.1, fd_graph_links$step.2))) | |
names(fd_nodes) <- "name" | |
fd_nodes$nodevalue <- as.numeric(row.names(fd_nodes)) - 1 |
This file contains hidden or 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 pandas as pd | |
from matplotlib import pyplot as plt | |
import matplotlib as mpl | |
import seaborn as sns | |
%matplotlib inline | |
#Read in data & create total column | |
stacked_bar_data = pd.read_csv("C:\stacked_bar.csv") | |
stacked_bar_data["total"] = stacked_bar_data.Series1 + stacked_bar_data.Series2 |
This file contains hidden or 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
library("RSiteCatalyst") | |
library("d3Network") | |
#### Authentication | |
SCAuth("key", "secret") | |
#### Get Pathing data: Single page, then ::anything:: pattern | |
pathpattern <- c("http://randyzwitch.com/big-data-hadoop-amazon-ec2-cloudera-part-1", "::anything::") | |
next_page <- QueuePathing("zwitchdev", | |
"2014-01-01", |