Skip to content

Instantly share code, notes, and snippets.

James Thomson jamesthomson

Block or report user

Report or block jamesthomson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jamesthomson
jamesthomson / install from github.R
Created Jul 30, 2014
install R package from github
View install from github.R
install.packages("devtools")
library("devtools")
install_github("jamesthomson/R2D3")
View gist:d68002a7d80de7a2095c
library(SpotifyAPI)
out<-visDiscography(artist="Shuggie Otis", output_file="Shuggie Disco.html")
View r2d3 demo.R
data(counties)
JSON<-jsonNestedData(structure=counties[,1:3], values=counties[,4], top_label="UK")
D3Tree(JSON, file_out="Tree.html")
hc.ave <- hclust(dist(USArrests), "ave")
hc.single <- hclust(dist(USArrests), "single")
hc.ward <- hclust(dist(USArrests), "ward.D")
cut.ave<-cutree(hc.ave, k=6)
View bpi_plotly.R
bpi_genre_sales_perc <- read.csv("http://myinspirationinformation.com/wp-content/uploads/2014/08/bpi_genre_sales_perc.csv")
bpi_sales_revenue <- read.csv("http://myinspirationinformation.com/wp-content/uploads/2014/08/bpi_sales_revenue.csv")
library(ggplot2)
library(reshape2)
library(ggthemes)
library(plotly)
sales_perc_melt<-melt(bpi_genre_sales_perc)
sales_perc_albums<-sales_perc_melt[sales_perc_melt$Type=="Albums",]
View Timing a Neural Net Scoring Process.R
library(nnet)
library(ggplot2)
neuralNetScoreTime<-function(var, score){
modelset<-NULL
for (i in 1:var) {
eval(parse(text=paste0("temp.", i, "<-rnorm(150, mean=1, sd=1)")))
eval(parse(text=paste0("modelset<-cbind(modelset, temp.", i, ")")))
View lastfmApp_ui.R
# ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("Lastfm Dashboard"),
sidebarLayout(position ="left",
sidebarPanel(
img(src = "logo.png", height = 80, width = 80),
View lastfmApp_server.R
#server.r
library(shiny)
shinyServer(function(input, output) {
library(rjson)
library(ggplot2)
library(grid)
View msd_song_length_analysis.sql
DROP TABLE IF EXISTS msd_data;
CREATE EXTERNAL TABLE msd_data
(
ref string,
analysis_sample_rate float ,
artist_7digitalid int ,
artist_familiarity float ,
View msd_files_list.R
library(XML)
#read url
search<-readLines('http://tbmmsd.s3.amazonaws.com/')
#convert to data.frame
df<-xmlToDataFrame(search)
#pull out files list
Files<-df$Key
#clean up NAs
Files2<-Files[!is.na(Files)]
View visualising 7plus songs.R
#import all data add column headers and run checks
dist <- read.delim("~/Documents/my blog/million song database/7plus songs/output1.txt", header=FALSE)
colnames(dist)<-c('length', 'freq')
dist
dist_time <- read.csv("~/Documents/my blog/million song database/7plus songs/output2.txt", header=FALSE)
You can’t perform that action at this time.