Skip to content

Instantly share code, notes, and snippets.

View sharan-naribole's full-sized avatar

Sharan Naribole sharan-naribole

View GitHub Profile
@sharan-naribole
sharan-naribole / dplyr_lazyeval.R
Last active February 24, 2017 21:24
dplyr lazyeval sample
example <- function(df, column_name, input_vec) {
# INPUTS:
# df : data frame
# column_name : string value of column name in df
# input_vec : character vector of values in column_name of df
# OUTPUTS:
# df : filtered dataframe
# Main reason for using this is because df$column_name throws
# error as column_name is not a column in df
@sharan-naribole
sharan-naribole / rdrop2_shiny.R
Created February 24, 2017 21:00
Example to illustrate using rdrop2 to access Dropbox files on Shiny server
token <- drop_auth()
saveRDS(token, "droptoken.rds")
# Upload droptoken to your server
# ** Don't share this with anyone **
# You can then revoke the rdrop2 app from your
# dropbox account and start over.
# ******** WARNING ********
# read it back with readRDS
token <- readRDS("droptoken.rds")
token <- drop_auth()
saveRDS(token, "droptoken.rds")
# Upload droptoken to your server
# ** Don't share this with anyone **
# You can then revoke the rdrop2 app from your
# dropbox account and start over.
# ******** WARNING ********
# read it back with readRDS
token <- readRDS("droptoken.rds")
@sharan-naribole
sharan-naribole / map.R
Created February 24, 2017 19:52
Map plot for H-1B Shiny
require(ggmap)
require(ggrepel)
require(dplyr)
require(ggplot2)
USA = map_data(map = "usa")
# Layer 1: USA Map
ggplot(USA, aes(x=long, y=lat)) +
geom_polygon() + xlab("Longitude (deg)") + ylab("Latitude(deg)") +