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 code produces an error at startup | |
| require(miniUI) | |
| require(shiny) | |
| ff <- function () | |
| { | |
| ui <- miniPage( | |
| gadgetTitleBar("Variable Profiler"), |
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
| selectConn <- function() { | |
| ui <- miniPage( | |
| gadgetTitleBar("ODBC Connect"), | |
| miniContentPanel( | |
| selectInput('server', 'Server', c( | |
| 'SQL Server', | |
| 'Postgres' | |
| ), width='100%'), | |
| p(strong('Port')), | |
| verbatimTextOutput("selectedPort"), |
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
| # Turn on profvis in RStudio first and run this code second | |
| # No preview panel appears and flamechart does not represent | |
| library(profvis) | |
| # Generate data | |
| times <- 4e5 | |
| cols <- 150 | |
| data <- as.data.frame(x = matrix(rnorm(times * cols, mean = 5), ncol = cols)) | |
| data <- cbind(id = paste0("g", seq_len(times)), 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
| ############ RStudio Server Pro ############## | |
| # Add group | |
| sudo groupadd -g 800 guests | |
| sudo groupadd -g 801 rstudio-superuser-admins | |
| sudo groupadd -g 802 admins | |
| sudo groupadd -g 803 rstudio | |
| sudo groupadd -g 804 rstudio-admins |
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(microbenchmark) | |
| N <- 1000 | |
| X <- matrix(rnorm(N*10), nrow = N) | |
| y <- rnorm(N) | |
| write.csv(X, outfile <- tempfile()) | |
| microbenchmark( | |
| Compute = lm.fit(X, y), | |
| Write = write.csv(X, outfile), |
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(readr) | |
| ### Generate large dataset on disk | |
| numBlocks <- 10 | |
| blockSize <- 1000 | |
| x <- iris | |
| ff <- tempfile() | |
| for(i in 1:numBlocks){ | |
| samp <- sample(1:nrow(x), blockSize, replace = T) | |
| write_csv(x[samp, ], ff, append = i > 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
| ### Download Air On Time data ### | |
| sudo rm -rd /tmp/flights | |
| sudo mkdir /tmp/flights | |
| for i in {1987..2008} | |
| do | |
| fnam=$i.csv.bz2 | |
| sudo wget -O /tmp/flights/$fnam http://stat-computing.org/dataexpo/2009/$fnam | |
| done |
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
| ### Compare SQLite to Spark | |
| ### June 5, 2016 | |
| ### EC2 4 Core 16 Gb RAM | |
| ### Install ### | |
| # Install | |
| devtools::install_github("hadley/devtools") | |
| devtools::install_github("hadley/dplyr") | |
| devtools::install_github("rstudio/rspark", auth_token = "XXXXXXXXXX") |
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
| --- | |
| title: "Python and R with Feather" | |
| output: html_notebook | |
| --- | |
| ```{r setup, include=FALSE} | |
| library(feather) | |
| library(ggplot2) | |
| setwd('/home/nathan/sol-eng-sales/vignettes/notebooks/demos/5-feather') | |
| ``` |
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
| # Test loading data into remote spark instance | |
| library(rspark) | |
| # Connect | |
| sc3 <- spark_connect("spark://54.245.95.88:7077") | |
| db3 <- src_spark(sc3) | |
| # Load CSV | |
| cat('Michael, 29\n', file='people.csv', append = FALSE) |
OlderNewer