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
| ds <- read.csv("dataset.csv") | |
| ## rainbow palette with gradients! | |
| palette(rainbow(10, alpha=.5)) | |
| plot(c(rep(1,5), rep(.2,5)), ds[,4], pch=21, cex=(seq(1,10)-1) %% 5 +1, col=ds[,2]+1, bg=ds[,2]+1, xlim=c(-1,19), ylim=c(-1,7), axes=F, | |
| xlab="x axis name", ylab="y axis name", main="Give a name to your chart") | |
| for(i in 1:8){ | |
| par(new=T) |
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
| ds <- read.csv("that_csv_file.csv") | |
| names(ds) <- c("test", "time", "city", "renderstart") | |
| ds$time <- as.POSIXct(strptime(ds$time, format="%m/%d/%y %H:%M")) | |
| ds$city <- as.character(ds$city) | |
| ds$test <- as.character(ds$test) | |
| cities <- names(sort(table(ds$city))) | |
| tests <- names(sort(table(ds$test))) | |
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
| # > head(ds) | |
| # hour activated organic viral | |
| # 1 2011-05-22 17:00:00 28 9 19 | |
| # 2 2011-05-22 18:00:00 47 12 35 | |
| # 3 2011-05-22 19:00:00 42 13 29 | |
| # 4 2011-05-22 20:00:00 57 13 44 | |
| # 5 2011-05-22 21:00:00 48 19 29 | |
| # 6 2011-05-22 22:00:00 86 19 67 | |
| # > dim(ds) |
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
| ## protovis style color cat10 | |
| palette(c("#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf")) | |
| palette(rainbow(11, alpha=.8)) |
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
| scl = 3 | |
| r = .3 ## roundness of the rectangles | |
| size(100*scl, 100*scl) | |
| w=10*scl | |
| mat1=[ | |
| [0,2,2,0,2,2,2,0], | |
| [1,0,0,1,2,0,0,2], | |
| [1,0,0,1,2,0,0,2], | |
| [1,0,0,1,2,0,0,2], |
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
| ## here's how you do a "SELECT col1,col2,col3,col4, count(1) AS cnt FROM ds_subs_less_table GROUP BY 1,2,3,4" thing in R ## | |
| # first, find out all the unique combos of col1,col2,col3,col4 | |
| subs.geo <- data.frame(unique(cbind( | |
| as.character(ds.subs.less$source_tz), as.character(ds.subs.less$source_country), | |
| as.character(ds.subs.less$target_tz), as.character(ds.subs.less$target_country) | |
| ))) | |
| names(subs.geo) <- c("source_tz", "source_country", "target_tz", "target_country") | |
| # next, figure out the frequency of each combo shows up |
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
| select sub.query_id, sub.result, sub.sql, | |
| avg(sub.time_lapse) as avg_time, | |
| max(sub.started_at) as last_run_at, | |
| count(1) as cnt | |
| from | |
| ( | |
| select qe.query_id, | |
| qe.result, | |
| qe.started_at, | |
| (qe.finished_at - qe.started_at) time_lapse, |
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
| SELECT FIRST_VALUE(pkey_id) OVER(PARTITION BY cnt ORDER BY cnt DESC, pkey_id) | |
| AS first_id | |
| FROM ( | |
| SELECT pkey_id, | |
| COUNT(*) AS cnt | |
| FROM dimension_attribute_histories | |
| GROUP BY 1 | |
| )sub | |
| LIMIT 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
| SELECT sub2.period_id, sub2.time_id, sub2.network_id, COUNT(1) as cnt | |
| FROM ( | |
| SELECT sub1.period_id, | |
| sub1.time_id, | |
| sub1.network_id, | |
| SUM(sub1.pct_squared) AS dept_concentration_hhi | |
| FROM (SELECT sub.period_id, | |
| sub.time_id, | |
| sub.network_id, | |
| sub.job_type, |
OlderNewer