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
## load rtweet | |
library(rtweet) | |
## store bounding box coordinates for state of nevada | |
nv <- c(-120.00647, 35.00186, -114.03965, 42.00221) | |
## initialize output vector and Midwestern 'ope' counter | |
s <- list() | |
ope <- 0L |
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
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor | |
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password | |
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility | |
-- 4. Enable Applescript Editor and System UI Server | |
-- 5. Trigger script from the menu | |
-- 6. Enjoy being connected | |
tell application "Cisco AnyConnect Secure Mobility Client" | |
activate | |
end tell |
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
bytes2char <- function(x) { | |
m <- gregexpr("<[[:alnum:]]{2}>", x) | |
y <- regmatches(x, m)[[1]] | |
y <- gsub("^<|>$", "", y) | |
y <- strsplit(y, "[><]+") | |
regmatches(x, m) <- list(sapply(y, function(.x) rawToChar(as.raw(paste0("0x", .x))))) | |
x | |
} | |
## read in string with bytes |
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
## generate data set | |
x2 <- rnorm(200) | |
x1 <- x2 + rnorm(200) | |
y2 <- rnorm(200) + x2 | |
y1 <- y2 + rnorm(200) | |
z2 <- rnorm(200) + y2 | |
z1 <- z2 + rnorm(200) | |
d <- data.frame(x1, x2, y1, y2, z1, z2) | |
## specify null and full models |
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/env Rscript | |
##keynote.R v1.0 Damon Kiesow @dkiesow | |
##Use with the Keynote rTweet AppleScript app to automate threaded tweeting during Keynote presentations | |
## | |
## load rtweet package | |
library(rtweet) | |
me <- rtweet:::home_user() | |
## Pull parameters from command line (first_status will be "yes" or "no" and provided from the AppleScript) | |
args <- commandArgs(trailingOnly = TRUE) |
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 |
NewerOlder