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
| clear | |
| input str500 x | |
| "-73.974651 40.73868,-73.973391 40.73897,-73.97323 40.73955,-73.97298 40.7415304,-73.97247 40.7423406,-73.97229 40.7428504,-73.97213 40.74338,-73.971871 40.7440804,-73.97141 40.7446706,-73.97103 40.7455605,-73.970301 40.7465204,-73.96929 40.7472" | |
| "-73.970301 40.7465204,-73.96929 40.7472" | |
| end | |
| // keep only the first pair of coordinates | |
| replace x = regexr(x, ",.*", "") | |
| // split by space, converting to numeric |
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
| # ============================================================================== | |
| # SESSION_INFO | |
| # | |
| # A script to deal with package dependencies that will | |
| # | |
| # - detach all packages except base ones | |
| # - install its own package dependencies | |
| # - look for session_info.txt and parse it for packages | |
| # - ensure the packages are installed and up to date | |
| # |
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 package | |
| library(ggplot2) | |
| # write function | |
| label_facets <- function(string){ | |
| len <- length(string) | |
| string = paste('(', letters[1:len], ') ', string, sep = '') | |
| return(string) | |
| } |
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
| <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS_HTML" async></script> | |
| <script type="text/x-mathjax-config"> | |
| MathJax.Hub.Config({ | |
| tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]} | |
| }); | |
| </script> |
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
| # enable CORS policy | |
| # https://gist.github.com/maxparm/3105526 | |
| <IfModule mod_rewrite.c> | |
| Header add Access-Control-Allow-Origin "*" | |
| Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT" | |
| Header add Access-Control-Allow-Headers: "Content-Type" | |
| RewriteEngine on | |
| RewriteBase / | |
| </IfModule> |
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
| --- | |
| title: "World maps" | |
| output: | |
| html_document: | |
| df_print: paged | |
| --- | |
| ```{r echo = FALSE, message = FALSE} | |
| library(tidyverse) | |
| library(sf) |
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/local/bin/python3 | |
| # coding: utf8 | |
| from bs4 import BeautifulSoup # pip install BeautifulSoup4 | |
| import os | |
| import re | |
| import sys | |
| import urllib.request | |
| u = sys.argv[1] |
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
| library(rvest) | |
| library(lubridate) | |
| library(tidyverse) | |
| Truman <- read_html("http://www.presidency.ucsb.edu/data/popularity.php?pres=33") | |
| Truman %>% | |
| html_table(fill=T) -> Truman | |
| Truman[[11]] -> Truman |
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
| library(segmented) | |
| library(tidyverse) | |
| dat <- structure(list(Pollster = structure(c(2L, 2L, 2L, 2L, 2L, 2L, | |
| 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, | |
| 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, | |
| 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Poll by gfk", | |
| "Poll by YouGov"), class = "factor"), Fieldwork.end.date = structure(c(17539, | |
| 17520, 17511, 17505, 17478, 17463, 17459, 17458, 17450, 17433, | |
| 17409, 17400, 17379, 17366, 17358, 17339, 17330, 17324, 17317, |
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
| # MP4 | |
| # requirements: | |
| # brew install youtube-dl | |
| # usage: yt-mp4 <youtube-URL> | |
| alias yt-mp4="youtube-dl -f 'best[height=720]'" | |
| # MP3 | |
| # requirements: |