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(dplyr) | |
library(ggplot2) | |
iris %>% | |
group_by(Species) %>% | |
summarize( | |
lower=quantile(Sepal.Length, .25), | |
upper=quantile(Sepal.Length, .75), | |
med=median(Sepal.Length), | |
avg=mean(Sepal.Length), |
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
/* | |
In this example I create two matrices in the same manner, extract the diagonal, and then turn the nx1 | |
matrix of the diagonal values into a diagonal matrix by calling `diag` again. When the initial matrix contains all 1s, | |
it works as expected. However, when the initial matrix contains all zeros, the second `diag` does not convert the nx1 | |
matrix of diagonal values to a diagonal matrix. I can work around this behavior, but I thought I should bring it to your attention. | |
*/ | |
val systemml_alg = | |
""" | |
fileOut1 = "" |
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
sql_query(cnxn, " | |
SELECT MIN(media_week_id) 'min_media_week', | |
MAX(media_week_id) 'max_media_week' | |
FROM availability_estimation_inputs | |
") |
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
#' @export | |
add_time_sig <- function(D) { | |
daypart_cols <- names(D)[grepl('hour_', names(D))] | |
# NOT CURRENTLY USED | |
#D <- D %>% | |
# mutate_( | |
# week_sig = ~ifelse(get_media_month(log_date) != get_media_month(detail_start), | |
# get_media_week(detail_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
get_p_id <- function(p_id, connection) { | |
sqlQuery(connection, sprintf( | |
"select p.id 'proposal_id', | |
pd.id 'proposal_detail_id', | |
mm.media_month, | |
b.name 'MVPD', | |
n.code 'network', | |
mpi.post_log_recieved_date 'log_date', | |
pd.start_date 'detail_start', | |
pd.end_date 'detail_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
vsel <- function (y, lag.max = 10, type = c("const", "trend", "both", | |
"none"), season = NULL, exogen = NULL) | |
{ | |
browser() | |
y <- as.matrix(y) | |
if (any(is.na(y))) | |
stop("\nNAs in y.\n") | |
colnames(y) <- make.names(colnames(y)) | |
K <- ncol(y) | |
lag.max <- abs(as.integer(lag.max)) |
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 instance, create key, install awscli, do awscli configure, | |
export AWS_ACCESS_KEY_ID=XX | |
export AWS_SECRET_ACCESS_KEY=XX | |
export SPARK_HOME=~/spark-1.4.1-bin-hadoop2.6 | |
$SPARK_HOME/ec2/spark-ec2 --key-pair=XX \ | |
--instance-type=m1.large \ | |
--zone us-east-1a \ | |
--identity-file=XX.pem \ |
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
x <- ggplot(mtcars, aes(x=mpg, y=disp, label=carb)) + | |
geom_point() + | |
geom_text(y=Inf, vjust=-.3) | |
g <- ggplotGrob(x) | |
g$layout$clip[g$layout$name == "panel"] = "off" | |
grid.draw(g) |
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
ui <- fluidPage( | |
selectInput('plot_type', 'Plot type', choices=c('point', 'line')), | |
sliderInput('n', 'N plots', value=1, min=1, max=100), | |
uiOutput('plots') | |
) | |
server <- function(input, output, session) { | |
output$plots <- renderUI({ | |
ptype <- input$plot_type |
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
# example1 (using grobs instead of grid.*) | |
vp <- vpTree( | |
parent=viewport(layout=grid.layout(nrow=2, ncol=2), name='parent'), | |
children=vpList( | |
viewport(layout.pos.row=1, layout.pos.col=1, name='vp1'), | |
viewport(layout.pos.row=1, layout.pos.col=2, name='vp2') | |
) | |
) | |
pushViewport(vp) | |
seekViewport('parent') |
NewerOlder