Skip to content

Instantly share code, notes, and snippets.

Avatar

yonicd

View GitHub Profile
@yonicd
yonicd / app.R
Created Oct 12, 2020
app example
View app.R
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 Apr 23, 2020
canvas shinyace
View canvasAce
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 Aug 17, 2019
harvesting cvs store locations
View cvs_rvest.R
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 Apr 12, 2019
code to retrieve @AnandWrites adhoc survey replies
View anandwrite_twitter_survey_replies.R
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 Feb 21, 2019
reliably find where script is run from in R
View runloc.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 Feb 17, 2019
ropenscilabs commit network using ghnet
View ghnet_ropenscilabs.R
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 Feb 12, 2019
timevis test
View .block
license: mit
@yonicd
yonicd / app.R
Created Jan 22, 2019
slick rtweet
View app.R
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 Jan 20, 2019
toddler in chief analysis
View toddleR.R
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])
You can’t perform that action at this time.