Skip to content

Instantly share code, notes, and snippets.

View ashutoshnanda's full-sized avatar

Ashutosh Nanda ashutoshnanda

View GitHub Profile
@ashutoshnanda
ashutoshnanda / server.R
Last active September 29, 2016 02:33
Code from Intro to Shiny (2016 DSSC Hackathon Preparation Session)
library(shiny)
shinyServer(function(input, output) {
data <- reactive({
if(input$distribution_type == 1) {
rnorm(n = 500, mean = input$parameter, sd = 1)
} else {
rpois(n = 500, lambda = input$parameter)
}
@ashutoshnanda
ashutoshnanda / code.R
Last active September 27, 2016 17:53
Code from Introduction to Programming in R (9/14)
3 * 8 / 39
pizza <- 10
pizza
View(pizza)
pizza <- 5
pizza ^ 5
c(1, 7, 13, 10)
c(1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10)
c(1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10)
c(1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1, 7, 13, 10, 1)
@ashutoshnanda
ashutoshnanda / server.R
Created March 7, 2016 23:56
DataSpace Code for March 7th, 2016 - Shiny!!
shinyServer(function(input, output) {
output$selectvalue <- renderPrint(
3 * as.numeric(input$myselectinput) + 5
)
output$slidervalue <- renderPrint(
input$mysliderinput * as.numeric(input$myselectinput)
)
output$plot <- renderPlot(
hist(rnorm(100, mean = input$mysliderinput))
)
@ashutoshnanda
ashutoshnanda / plot_with_ggplot2.R
Created March 1, 2016 00:02
Introduction to Plotting with ggplot2
install.packages("ggplot2")
library(ggplot2)
x <- rnorm(50)
x
ggplot() + geom_histogram(aes(x = x))
ggplot() + geom_histogram(aes(x = x), binwidth = 0.1)
x <- rnorm(500)
ggplot() + geom_histogram(aes(x = x), binwidth = 0.1)
length(x)
my.data <- rnorm(1000)
@ashutoshnanda
ashutoshnanda / level_5.ipynb
Created February 1, 2016 13:48
Introduction to Bokeh
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ashutoshnanda
ashutoshnanda / read_db.R
Last active November 26, 2015 07:13
This code (in both Python and R) will read from a SQLite database of Hillary Clinton's emails and display basic information about the database.
library(dplyr)
library(RSQLite)
#Set up connection to the SQLite database
connection <- dbConnect(RSQLite::SQLite(), dbname = "clinton.sqlite")
#Print all tables
print("Tables")
all_tables <- dbListTables(connection)
print(all_tables)