Skip to content

Instantly share code, notes, and snippets.

@edgararuiz-zz
edgararuiz-zz / serverplot.R
Created January 21, 2017 17:15
Histogram function
#' Build a Histogram
#'
#' Computes bins server side and creates the histogram inside R.
#'
#' @param data A Spark DataFrame (tbl_spark).
#' @param x Quoted name of column to use in the plot.
#' @param bins Number of bins to use. Defaults to 30.
#' @param output Type of plot returned. Current options are: "ggplot", "ggvis" & "shiny". The option "data" returns a data.frame.
#' @export
server_histogram <- function(
---
title: "Stock Presentation"
output: ioslides_presentation
params:
stock: GOOG
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE); knitr::opts_chunk$set(warning = FALSE) #-- Hide code and messages
library(magrittr); library(dygraphs) #-- Load needed libraries
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
# The following two commands remove any previously installed H2O packages for R.
if ("package:h2o" %in% search()) { detach("package:h2o", unload=TRUE) }
if ("h2o" %in% rownames(installed.packages())) { remove.packages("h2o") }
# Next, we download packages that H2O depends on.
pkgs <- c("methods","statmod","stats","graphics","RCurl","jsonlite","tools","utils")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
}
devtools::install_github("rstats-db/odbc", ref = "transactions", force = TRUE)
library(odbc)
odbcHiveCon <- dbConnect(odbc(),
Driver = "Hive Driver",
host = "ec2-52-35-222-37.us-west-2.compute.amazonaws.com",
Schema = "default",
UID = "rstudio",
PWD = "rstudio",
port = 10000)
library(shinydashboard)
library(dplyr)
library(dbplyr)
library(purrr)
library(shiny)
library(highcharter)
library(DT)
library(htmltools)
# Use the `config` package to get the credentials
library(shinydashboard)
library(dplyr)
library(dbplyr)
library(purrr)
library(shiny)
library(highcharter)
library(DT)
library(htmltools)
# Use the `config` package to get the credentials
library(shinydashboard)
library(dplyr)
library(dbplyr)
library(purrr)
library(shiny)
library(highcharter)
library(DT)
library(htmltools)
library(nycflights13)
library(tfestimators)
library(titanic)
library(dplyr)
library(purrr)
titanic_set <- titanic_train %>%
filter(!is.na(Age))
library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), path = ":memory:")
db_mtcars <- copy_to(con, mtcars)
DBI::dbListTables(con)
db_mtcars %>%
filter(am == 1) %>%
show_query()