Skip to content

Instantly share code, notes, and snippets.

View muschellij2's full-sized avatar

John Muschelli muschellij2

View GitHub Profile
brew tap homebrew-ffmpeg/ffmpeg
brew install homebrew-ffmpeg/ffmpeg/ffmpeg --with-chromaprint /
--with-fdk-aac /
--with-game-music-emu /
--with-libbluray /
--with-libbs2b /
--with-libcaca /
--with-libgsm /
--with-libmodplug /
--with-librsvg /
library(dplyr)
if (getRversion() >= "3.6.0") {
set.seed(234)
} else {
# RNGversion("3.5.0")
set.seed(1)
}
# creating example data
n = 20
ids = 1:n
@muschellij2
muschellij2 / fst_stuff.R
Last active June 6, 2019 18:15
Example of using FST data
library(ActivityIndex)
library(fst)
library(lubridate)
library(data.table)
filename = system.file("extdata","sample_GT3X+.csv.gz",
package = "ActivityIndex")
res = ActivityIndex::ReadGT3XPlus(filename)
data = res$Raw
data$DT = paste(data$Date, data$Time)
## Performs MCMC P-value calculation for 0-1 tables
## from Darwin's Finch data
set.seed(1)
I = 7; J = 5
testDat = matrix(sample(0:1, I * J, replace= TRUE), I, J)
A = matrix(c(
0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
library(ggplot2)
library(plotly)
library(htmlwidgets)
make_card = function(handle = "@StrictlyStat",
title = "",
description = "",
img = NULL,
html = NULL,
height = 480,
@muschellij2
muschellij2 / script_to_gif.R
Created March 4, 2019 03:04
Take an R Script and make it into a gif.
library(rsciinema)
input = paste0("library(magrittr); # a comment is a gra", backspace(), "eat thing to do",
"\niris %>% \n dplyr::group_by(Species) %>%\n ",
"dplyr::summarise_all(mean) \n # a new line")
data = asciicast( input )
json = rsciinema::json_asciicast(data)
@muschellij2
muschellij2 / Ioannidis_publications_scopus.R
Last active January 23, 2019 22:34
Publications of John Ioannidis from Scopus
# Nature article: https://www.nature.com/articles/d41586-018-06185-8
library(rscopus)
library(lubridate)
library(dplyr)
x = author_data(first_name = "john", last_name = "Ioannidis")
df = x$df
df$date = ymd(df$`prism:coverDate`)
df$year = year(df$date)
library(pdftools)
library(purrr)
res = pdftools::pdf_text("YG-Archive-DatingSocialMediaInternal-090818.pdf")
ss = strsplit(res, "\n")
names(ss) = 1:length(ss)
df = map_df(ss, function(x) {
data.frame(txt = x,
row = seq_along(x),
start = grepl("unweighted base", tolower(trimws(x))),
stringsAsFactors = FALSE)
@muschellij2
muschellij2 / rsciinema_example.R
Created November 16, 2018 16:56
rsciinema Example
library(rsciinema)
data = asciicast( "# a comment\niris %>% \n dplyr::group_by(Species) %>%\n dplyr::summarise_all(mean)" )
tfile= tempfile(fileext = ".cast")
write_asciicast(data, tfile)
asciinema( tfile )
# see http://www.opc.state.md.us/RegulatoryActivities/Publications.aspx
# https://webapp.psc.state.md.us/ecm/web/Compare_new1.cfm
library(rvest)
library(dplyr)
# doc = read_html("rates.html")
# tab = html_table(doc, header = TRUE)[[1]]
# tab = tab %>%
# rename(
# name = `Company Name3`,
# price = `Price/KWH`,