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
| * Marginal means in Stata | |
| * https://www.stata.com/features/overview/marginal-analysis/ | |
| * Probit | |
| webuse nlsw88, clear | |
| quietly probit union wage c.age c.age#c.age collgrad | |
| margins, dydx(age) |
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
| # https://ryan-holben.github.io/tex/latex/installation/macos/2016/08/21/installing-tex-on-mac/ | |
| brew cask install basictex | |
| sudo tlmgr update --self | |
| sudo tlmgr install texliveonfly | |
| sudo tlmgr install latexmk | |
| sudo tlmgr install biber | |
| sudo tlmgr install standalone | |
| sudo tlmgr install preview |
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
| # Required packages | |
| # dplyr | |
| # stringr | |
| # glue | |
| lookfor <- function(df, pattern) { | |
| var_i <- names(df) %>% stringr::str_detect(stringr::regex(pattern, ignore_case = TRUE)) | |
| return(names(df)[var_i]) | |
| } |
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(gapminder) | |
| library(tidyverse) | |
| library(broom) | |
| library(huxtable) | |
| library(lfe) | |
| # Example dataset (via gapminder package) | |
| glimpse(gapminder) | |
| # Create a function to make looping easier |
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
| Wrong mean: 5.84333333333333 | |
| Right mean: 5.936 | |
| The wrong mean didn't filter: 5.84333333333333 |
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
| require 'mini_exiftool' | |
| photo = MiniExiftool.new('new.jpg') | |
| photo.tags.sort.each do |tag| | |
| photo.copy_tags_from('original.jpg', tag) | |
| end | |
| photo.save |
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
| brew tap caskroom/cask | |
| brew install brew-cask | |
| brew install Caskroom/cask/xquartz | |
| brew cask install java | |
| brew tap homebrew/science | |
| brew install R | |
| brew install Caskroom/cask/rstudio |
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
| using JuMP, Ipopt | |
| A = 1; δ = 0.1; θ = 0.3; β = 0.96; ɛ = 0.5; χ = 0.5; | |
| r = (1 / β) - (1 - δ); | |
| m = Model(solver = IpoptSolver()) | |
| @variable(m, 0 <= k <= Inf) | |
| @variable(m, 0 <= n <= Inf) | |
| @variable(m, 0 <= w <= Inf) |
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
| Dir.glob('*.mp3') do | the_filename | | |
| track = the_filename[0..2].strip() | |
| File.rename(the_filename, "05-#{track}.mp3") | |
| end |
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/bin/env python | |
| from lxml import html | |
| import requests | |
| import nltk | |
| page = requests.get('http://nytimes.com') | |
| tree = html.fromstring(page.text) | |
| top_stories = tree.xpath('//*[@id="top-news"]/*//h2/a/text()') | |
| more_stories = tree.xpath('//*[@id="main"]/div[10]/*//article/h2/a/text()') | |
| all_stories = top_stories + more_stories |