layout | title | description | tags | ||
---|---|---|---|---|---|
default |
SQL Style Guide |
A guide to writing clean, clear, and consistent SQL. |
|
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(rgdal) | |
library(dplyr) | |
library(readr) | |
library(stringi) | |
library(stringr) | |
library(tidyr) | |
library(grid) | |
library(scales) | |
library(ggplot2) | |
library(ggthemes) |
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
# | |
# This is a toy example of splitting an R application | |
# into three distinct parts: | |
# | |
# - Loading the data | |
# - Calculating the analytics | |
# - Rendering an RMarkdown document | |
# | |
# Note: The RMarkdown doc appears in a companion file, toyDoc.Rmd. | |
# |
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
// Change the amount here to create more records | |
SET vAmountTransactions=10000; | |
Characters: | |
Load Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26; | |
ASCII: | |
Load | |
if(RecNo()>=65 and RecNo()<=90,RecNo()-64) as Num, | |
Chr(RecNo()) as AsciiAlpha, |
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
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list' | |
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 | |
gpg -a --export E084DAB9 | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get -y install r-base libapparmor1 libcurl4-gnutls-dev libxml2-dev libssl-dev gdebi-core | |
sudo apt-get install libcairo2-dev | |
sudo apt-get install libxt-dev | |
sudo apt-get install git-core | |
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024 |
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
if(!require("ggseas")) install.packages("ggseas") | |
if(!require("forecast")) install.packages("forecast") | |
if(!require("data.table")) install.packages("data.table") | |
if(!require("knitr")) install.packages("knitr") | |
library(ggseas) | |
library(forecast) | |
library(data.table) | |
# Get data |
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
require(data.table) | |
require(lubridate) | |
#create the data frames | |
#x is a data table with a list of events to match against the different dates in x to see if there is overlap | |
x = data.table( | |
eventid=c(1,2,3), | |
start =mdy_hms(c('10/1/2016 04:30:00','10/1/2016 18:02:00','10/2/2016 14:21:00')), | |
end =mdy_hms(c('10/1/2016 05:43:00','10/2/2016 01:23:00','10/4/2016 08:54:00')) |
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
testvector <- c(.5, .1, .2, .9, .9, .2, .5) | |
# group rows based on cumsum with reset | |
cumsum_group <- function(x, threshold) { | |
cumsum <- 0 | |
group <- 1 | |
result <- numeric() | |
for (i in 1:length(x)) { | |
cumsum <- cumsum + x[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
library(data.table) | |
?`[.data.table` | |
DT <- data.table(x=rep(c("b","a","c"),each=3), y=c(1,3,6), v=1:9) | |
X <- data.table(x=c("c","b"), v=8:7, foo=c(4,2)) | |
colnames(DT) | |
# [1] "x" "y" "v" |
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 a tibble with the artist's name & another with the album title | |
kdot_albums <- tibble( | |
artist = "Kendrick Lamar", | |
album = c("Section 80", "DAMN.")) | |
# Iterate through the albums and artists using a map call | |
album_lyrics <- kdot_albums %>% | |
mutate(tracks = map2(artist, album, genius_album)) |