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
julia> using ODBC | |
julia> ODBC.connect("MySQL") | |
Connection 1 to MySQL successful. | |
#Save query results into a DataFrame called 'results' | |
julia> results = query("Select * from a1987;"); | |
julia> typeof(results) | |
DataFrame (use methods(DataFrame) to see constructors) |
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
#Run until version > 1.0 on CRAN | |
library(devtools) | |
install_github("RSiteCatalyst", "randyzwitch", ref = "master") | |
#Run if version >= 1.1 on CRAN | |
library("RSiteCatalyst") | |
#API Authentication | |
SCAuth(<username:company>, <shared_secret>) |
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
#Plot data using ggplot2 | |
library(ggplot2) | |
#Combine year/month/day together into POSIX | |
pageviews_w_forecast$date <- ISOdate(pageviews_w_forecast$year, pageviews_w_forecast$month, pageviews_w_forecast$day) | |
#Convert columns to numeric | |
pageviews_w_forecast$pageviews <- as.numeric(pageviews_w_forecast$pageviews) | |
pageviews_w_forecast$pageviews_upper <- as.numeric(pageviews_w_forecast$pageviews_upper) | |
pageviews_w_forecast$pageviews_lower <- as.numeric(pageviews_w_forecast$pageviews_lower) |
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
-- Create table from yearly airline csv files | |
CREATE EXTERNAL TABLE airline ( | |
`Year` int, | |
`Month` int, | |
`DayofMonth` int, | |
`DayOfWeek` int, | |
`DepTime` int, | |
`CRSDepTime` int, | |
`ArrTime` int, | |
`CRSArrTime` int, |
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
-- Create view to "remove" 22 bad records from our table | |
create view vw_airline as | |
select * from airline | |
where uniquecarrier <> "UniqueCarrier"; |
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
#Python/pypy | |
import math | |
def smallestdivisall(n): | |
for i in xrange(1, math.factorial(n)+1): | |
for j in xrange(1, n+1): | |
if i % j != 0: | |
break | |
elif j == n: | |
return i | |
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
function smallestdivisall(n::Int64) | |
for i = 1:factorial(n) | |
for j = 1:n | |
if i % j !=0 | |
break | |
elseif j == n | |
return i | |
end | |
end | |
end |
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(ggplot2) | |
library(reshape2) | |
jit <- read.csv("~/Desktop/jit.csv") | |
#Melt data into proper format | |
jitm <- melt(jit, id.vars='numsearch') | |
jitm$value = log(jitm$value) | |
#Create Overall ggplot for ln performance |
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(ggplot2) | |
# This example uses the ChickWeight dataset, which comes with ggplot2 | |
# First plot | |
p1 <- | |
ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet, group=Chick)) + | |
geom_line() + | |
ggtitle("Growth curve for individual chicks") | |
# Second plot |
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
#### 0. Setup | |
library("RSiteCatalyst") | |
library("RTextTools") #Loads many packages useful for text mining | |
#### 1. RSiteCatalyst code - Get Natural Search Keywords & Metrics | |
#Set credentials | |
SCAuth(<username:company>, <shared secret>) | |
#Get list of search engine terms |