Ya Xu

Ya’s Notebook

(Things I’ve found useful)

Useful links


R tricks and functions
  • Type math notations: plot(x, y, xlab=expression(theta)) (See ?plotmath for more options)

  • No more grid search for tuning parameters! Use picktune to avoid this and get this.

  • Want an orthogonal matrix with arbitrary zeros? Use Jacob Bien’s sportho.

Have a cute R function you are proud of? Email Ya

Some useful Linux/Unix commands:
  • convert: convert image.jpg image.pdf

  • sed: sed -n 18p filename #print line 18 from file (see here for more)

  • screen: “Ctrl-s” freezes screen, and can be undone by “Ctrl-q” (see here for more)

  • wget:

    • download all pdfs on a page: wget -r -l1 --no-parent -A.pdf http://www.example.com/

    • download the title page index.html: wget -p -k http://www.example.com/

  • Email with attachment: echo “you are genius” | mutt -a genius.pdf xxx@stanford.edu

  • Only list directories: ls -l | egrep ‘^d’

  • Find R scripts containing “latex” in all (sub)directories: find . -name “*.R” -exec grep “latex” ‘{}’ \; -print

  • To draw an underline: use \uline{} from ulem package instead of \underline{} to avoid excessive underline space for tall/low letters (such as “g” and “y”).

  • To produce horizontal lines in text: use \rule[raise-height]{width}{thickness}

  • To produce table with auto white column space given total width: \begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill}}lr}\end{tabular*}

  • Use psfrag to overlay .ps figures with latex texts - the best way to get fonts consistent with the rest of the writing and to get nice math equations. See wiki.

The easiest way (I’ve found) to draw a picture for beamer slides:

(1) Use powerpoint to make the picture
(2) Save as pdf
(3) If necessary, convert pdf to eps (not ps) format to be included in LaTeX

SSH over an http proxy:

(1) Get corksrew and compile
(2) Add the following to the ssh config file: ProxyCommand folderlocation/corkscrew http-proxy 80 %h %p
(See here for more detailed instructions)