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
#------------------------------------------------------------------------------# | |
# API KEYS/SECRETS | |
#------------------------------------------------------------------------------# | |
# twitter keys - these are fake replace these with your twitter keys found | |
# at https://developer.twitter.com/en | |
# be careful with these – do not share or save to cloud. use environment | |
# variables, follow best practices, don't be careless :) | |
consumer_key = "IYWxHaPxjpalssdfkj" | |
consumer_secret = "Cyx8OqcOtniCe63ZmaPxvvq6HvstV6PuS1AjwY9g1awnbaIUp4" |
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
# _____ __ __ | |
# |__ / / /__ ____ _____ ____ ____/ / | |
# /_ <______/ / _ \/ __ `/ __ `/ _ \/ __ / | |
# ___/ /_____/ / __/ /_/ / /_/ / __/ /_/ / | |
# /____/ /_/\___/\__, /\__, /\___/\__,_/ | |
# /____//____/ | |
# RTWEET + 3-LEGGED-AUTH DEMO | |
# This code demonstrates how to do 3-legged authentication for Twitter | |
# using the {rtweet} package. Based heavily on code from Michael Kearney and Calli Gross |
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
## install these if not already | |
pkgs <- c("remotes", "syuzhet", "tfse", "rtweet", "ggplot2", "dplyr", "tidyr") | |
if (length(pkgs <- pkgs[!pkgs %in% installed.packages("remotes")]) > 0) { | |
install.packages(pkgs) | |
} | |
## install from github | |
remotes::install_github("mkearney/dataviz") | |
remotes::install_github("mkearney/dict") |
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
## load rtweet and congress116 | |
library(rtweet) | |
library(congress116) | |
## create long-version of congress116 data (and drop rows w/o screen names) | |
sns <- with(congress116, data.frame( | |
bioguide = c(bioguide, bioguide[!is.na(screen_name_personal)]), | |
handle = c(screen_name_official, screen_name_personal[!is.na(screen_name_personal)]), | |
stringsAsFactors = FALSE | |
)) |
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
#' Conditionally apply expressions on a data object | |
#' | |
#' @param .data Input data | |
#' @param condition A logical value to determine whether to use .if or .else | |
#' @param .if Formula or function to apply to intput data when condition is TRUE | |
#' @param .else Formula or function to apply to intput data when condition is FALSE | |
#' @return Output of appropriate .if/.else call | |
#' @export | |
#' @importFrom rlang as_closure | |
do_if_else <- function(.data, condition, .if, .else = identity) { |
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
## install packages (from CRAN) if not already | |
pkgs <- c("dplyr", "rtweet", "ggplot2", "syuzhet", "ggbeeswarm", "remotes") | |
if (any(!pkgs %in% installed.packages())) { | |
install.packages(pkgs[!pkgs %in% installed.packages()]) | |
} | |
## install {dataviz} theme from github | |
remotes::install_github("mkearney/dataviz") | |
## define paste function I really like rn |
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
## install {remotes} pkg | |
if (!requireNamespace("remotes", quietly = TRUE)) { | |
install.packages("remotes") | |
} | |
## install {tfse} from github | |
remotes::install_github("mkearney/tfse") | |
## load {tfse} | |
library(tfse) |
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(V8) | |
library(rvest) | |
library(hrbrthemes) | |
library(tidyverse) | |
ctx <- v8() | |
pg <- read_html("https://www.tiobe.com/tiobe-index/") | |
html_nodes(pg, xpath=".//script[contains(., 'series:')]") %>% |
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(stats) | |
library(VIM) | |
library(mice) | |
library(car) | |
library(Hmisc) | |
library(dplyr) | |
setwd('~/R') | |
#import and prepare the master data. | |
full_golf=read.csv('full_golf_new.csv',strip.white=T,stringsAsFactors=FALSE) |
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
#!/usr/bin/ruby | |
# For an OO language, this is distinctly procedural. Should probably fix that. | |
require 'json' | |
details = Hash.new({}) | |
capture_params = [ | |
{ :name => "title", :message => "Enter project name." }, | |
{ :name => "url", :message => "Enter the URL of the project repository." }, |
NewerOlder