Skip to content

Instantly share code, notes, and snippets.

View yonicd's full-sized avatar

yonicd

View GitHub Profile
@yonicd
yonicd / reactivity_drivers.R
Created December 22, 2020 01:48
compare reactivity in web drivers
# remotes::install_github(c('yonicd/reactor@73c6285','yonicd/puzzlemath@17def58'))
library(reactor)
library(puzzlemath)
obj1 <- init_reactor()%>%
set_golem_args(package_name = 'puzzlemath')%>%
set_chrome_driver(
chromever = chrome_version()
)%>%
start_reactor()
@yonicd
yonicd / app.R
Created October 12, 2020 20:27
app example
library(whereami)
library(ggplot2)
if(!file.exists('cars.csv')){
readr::write_csv(mtcars,path = 'cars.csv')
}
# Define the UI
ui <- fluidPage(
sidebarLayout(
@yonicd
yonicd / canvasAce
Last active April 23, 2020 20:31
canvas shinyace
library(shiny)
library(shinyAce)
modes <- getAceModes()
themes <- getAceThemes()
init <- "createData <- function(rows) {
data.frame(col1 = 1:rows, col2 = rnorm(rows))
}"
@yonicd
yonicd / cvs_rvest.R
Last active August 17, 2019 01:33
harvesting cvs store locations
library(xml2)
library(rvest)
library(glue)
library(dplyr)
library(purrr)
library(purrrogress)
library(ggmap)
library(ggplot2)
srm <- function(x,pat = '\\t+|\\n+',replace = '') gsub(pat,replace,x)
@yonicd
yonicd / anandwrite_twitter_survey_replies.R
Created April 12, 2019 13:24
code to retrieve @AnandWrites adhoc survey replies
library(magrittr)
library(rtweet)
root_status <- '1116361675618361345'
x1 <- rtweet::lookup_tweets(root_status)
# The question
cat(x1$text)
#> Who do you:
@yonicd
yonicd / runloc.R
Created February 21, 2019 18:49
reliably find where script is run from in R
runloc <- function(path_expand = FALSE){
src <- 'Untitled'
if(rstudioapi::getActiveDocumentContext()$id=='#console')
src <- 'Console'
if(length(getSrcFilename(sys.call(sys.nframe()-1)))>0)
src <- file.path(
getSrcDirectory(sys.call(sys.nframe()-1)),
@yonicd
yonicd / ghnet_ropenscilabs.R
Created February 17, 2019 19:06
ropenscilabs commit network using ghnet
remotes::install_github('yonicd/ghnet')
library(ghnet)
# get current github R repos using gepuro json file
universe <- fetch_gepuro()
# filter to ropenscilabs repos only
ropenscilabs_repos <- universe%>%
dplyr::filter(owner=='ropenscilabs')%>%
@yonicd
yonicd / .block
Last active February 12, 2019 12:38
timevis test
license: mit
@yonicd
yonicd / app.R
Created January 22, 2019 14:42
slick rtweet
library(rtweet)
library(slickR) # remotes::install_github('metrumresearchgroup/slickR')
tweets <- rtweet::search_tweets("#rstats", n = 5, include_rts = FALSE)
# https://github.com/mkearney/rtweet/pull/305/files
tweet_embed <- function(screen_name,status_id,...){
stem <- 'https://publish.twitter.com/oembed'
@yonicd
yonicd / toddleR.R
Created January 20, 2019 13:46
toddler in chief analysis
library(rvest)
library(patchwork)
tweet_threading <- function(tw){
last_found <- FALSE
while(!last_found){
nr <- nrow(tw)
last_found <- is.na(tw$reply_to_status_id[nr])