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
program define makebins, rclass | |
syntax varname, [PREfix(name) min(real 0) max(real 100) step(real 5) SEQuential DROPbin(real 70)] | |
local var `varlist' | |
if mod(`max' - `min',`step') != 0 { | |
di as error "Warning: Step size `step' does not divide evenly into range. Top bin may extend beyond `max'." | |
} | |
* Declare prefix | |
if "`prefix'" != "" { |
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
program define gen_heat_index | |
* Calculat heat index | |
* See https://en.wikipedia.org/wiki/Heat_index. Note that there is no exact heat index formula | |
* since it is defined by the table. There are approximations, but this code uses the table itself. | |
* The only modification is that I cap at 140. | |
syntax, DRYbulbtemp(varname) RELativehumidity(varname) [GENerate(string)] | |
if "`generate'" == "" { | |
local generate "heat_index" | |
} |
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
program define gen_relative_humidity | |
* Calculate relative humidity given dry bulb temperature and dew point | |
syntax, DRYbulbtemp(varname) DEWpoint(varname) [GENerate(string)] | |
* Inputs in F | |
local T `drybulbtemp' | |
local TD `dewpoint' | |
if "`generate'" == "" { | |
local generate "rel_humidity" | |
} |
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(foreign) | |
library(data.table) | |
library(zoo) | |
library(Hmisc) | |
library(gstat) | |
library(sp) | |
rm(list=ls()) | |
# Fill in missing data ---- | |
sm.thresh <- 0.9 # Min proportion of obs that must be in a station-month |
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
#!/bin/bash | |
DATE=`date "+%A, %b %d %Y"` | |
YESTERDAY=`date -v-1d "+%A, %b %d %Y"` | |
open "bear://x-callback-url/create?title=$DATE&text=## Beginning of day thoughts | |
## Goals | |
- | |
## End of day thoughts | |
[[$YESTERDAY]]&tags=dailylog" |
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(tinytex) | |
tlmgr_search('/times.sty') # search for times.sty | |
tlmgr_install('psnfss') # install the psnfss package | |
tlmgr_update() # update everything |
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
## Logging into server | |
ssh <server-address> | |
# Login | |
tmux | |
# CTRL-b d to detach tmux | |
exit | |
## When returning to server | |
tmux attach |
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
x <- c(5, 15, 2015) | |
sprintf(sprintf("%03d", x)) |
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
my.summary = function(x) list(mean = mean(x), median = median(x)) | |
DT[, as.list(unlist(lapply(.SD, my.summary))), .SDcols = c('a', 'b')] | |
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
points.shp <- points.shp[apply(sf::st_intersects(points.shp, polys), 1, any),] |
OlderNewer