Skip to content

Instantly share code, notes, and snippets.

@ColinFay
ColinFay / filled_template.html
Created March 24, 2021 08:04
html_template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<style>body{background-color:white;}</style>
</head>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
@joshuaulrich
joshuaulrich / intraday-sp500.R
Last active April 26, 2023 13:02
Track the S&P 500 throughout the trading day
require(quantmod)
do_chart <- function(symbol) {
quote <- getQuote(symbol)
quote$Close <- quote$Last
xts(OHLCV(quote), quote[,"Trade Time"],
pct_change = quote[,"% Change"])
}
filename <- "intraday-sp500.rds"
#
# ALERT: The most up-to-date version of this function is now available at
# https://github.com/rok-cesnovar/misc/blob/master/expose-cmdstanr-functions/expose_cmdstanr_functions.R
#
#' Function to expose Stan user-defined functions in R using CmdStanr and Rcpp.
#'
#' In addition to all user-defined functions, this function will expose the
#' stan_rng__(seed) function, that can be used to supplied specific seeds to
#' Stan RNG UDFs.
@kjhealy
kjhealy / apple-covid.R
Last active May 27, 2020 15:54
Get Apple's COVID data in R
## Get current Apple COVID data
## Kieran Healy / @kjhealy
## E.g. apple_covid <- get_apple_data()
## 1. Find today's URL
## Thanks to David Cabo (@dcabo) for alerting me to the existence of the json file.
get_apple_target <- function(cdn_url = "https://covid19-static.cdn-apple.com",
json_file = "covid19-mobility-data/current/v3/index.json") {
tf <- tempfile(fileext = ".json")
library(rlang)
#> Warning: package 'rlang' was built under R version 3.6.2
generator <- function() {
# ~ 80mb
x <- 1:1e7 + 0
# `x` is in this function env
function() {
1
library(RSelenium)
library(rvest)
library(tidyverse)
theme_set(theme_minimal(15) +
theme(plot.title.position = "plot",
plot.caption = element_text(color = "gray40", size = 8)))
url <- "https://www.nytimes.com/interactive/2020/us/coronavirus-us-cases.html"
rd <- rsDriver(browser = "chrome", chromever = "81.0.4044.69")
@mikedecr
mikedecr / smartly-reinstall-R-pkgs.R
Last active November 30, 2021 20:42
When you're installing packages after a major R upgrade and you DON'T just want to get everything from CRAN.
# ----------------------------------------------------
# Installing packages for new R version.
# Michael DeCrescenzo
#
# Hi, I'm a political science PhD student looking for
# a data science/quantitative research/statistics job.
# Learn more at <mikedecr.github.io> and <github.com/mikedecr>
#
# This script deals with the following problem:
# I upgraded to new major version of R, & I want to reinstall packages.
@clauswilke
clauswilke / CFR.Rmd
Created March 17, 2020 02:57
COVID-19 Case Fatality Rate (CFR) by age
---
title: "COVID-19 Case Fatality Rate (CFR) by age"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
```
rm(list = ls())
library(tidyverse)
library(ggrepel)
covid <-
read_csv(file = "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")
covid <-
covid %>% filter(`Country/Region` != "Cruise Ship")
covid_long <-
@gaborcsardi
gaborcsardi / Pkgdown deploy from Travis.md
Last active November 17, 2021 13:41
Walkthrough: deploy a pkgdown site from Travis

Run usethis::use_pkgdown_travis()

usethis::use_pkgdown_travis()
✔ Setting active project to '/Users/gaborcsardi/works/ps'Adding 'docs/' to '.gitignore'Set up deploy keys by running `travis::use_travis_deploy()`Insert the following code in '.travis.yml'
  before_cache: Rscript -e 'remotes::install_cran("pkgdown")'