Ryan's Blog

Latex scientific notation, made easy

Posted in latex by ryanlayer on January 13, 2012

\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}

Then, typing

The [111] crystal planes are 3.2\e{-10} m apart.

http://www.tapdancinggoats.com/easy-scientific-notation-in-latex.htm

R plot magic

Posted in Uncategorized by ryanlayer on January 12, 2012

To move the axis labels/lines:

par(mpg=c(, , ))

default is mpg=c(3,1,0), but mgp=c(1.75, 0.5, 0) works

To move margins:

par(mar=c(,,,))

default is mar=c(5,4,4,2)+0.1, but mar=c(3,3,0,0)+0.1 works

Using awk to randomly sample a file

Posted in Uncategorized by ryanlayer on January 6, 2012

Create a file with 1000 lines:

for i in {1..1000};do echo $i; done > f


export P=0.5
cat f | awk -v p=$P 'BEGIN{srand()} {r = rand(); if (r <= p) print}'

Follow

Get every new post delivered to your Inbox.