[ Unix/Linux | Emacs | LaTeX | R | Other ]
Send an email to Karl Broman (kbroman at jhsph.edu) if you have suggestions for additions, subtractions, clarifications, corrections, or modifications.
xlsfonts lists all the available fonts
/usr/X11R6/lib/X11/rgb.txt or (on athena)
/usr/openwin/lib/rgb.txt
scp is great for transferring files between
machines. (e.g. scp myfile athena:somedir/)
C-alt arrow
switches between workspaces.
convert for
converting images between formats.
.tcshrc in order to
search all .c and .h files
recursively, find instances of a given word in the file, and
print those instances along with the file names. (For example,
use fnd main)
alias fnd 'find . -name "*.[ch]" -exec grep \~* {} \; -print'
emacs or vi, you can determine the
current format. On enigma, use the commands
dos2unix and unix2dos to convert files
between formats. Use dos2unix -c Mac
filename if the file is in MacOS format.
Ctrl-S for searching.
Ctrl-x u for Ctrl-Shift-_ for
undo.
Esc-% (y/n/!) for replacement.
Ctrl-number character or Esc-number
character repeats that character.
! in directory listing mode executes a shell
command on that file.
.emacs
file:
(global-font-lock-mode t) (setq-default transient-mark-mode t)
emacs -nw when using emacs remotely over a slow
connection.
.emacs file for examples of macros
(~kbroman/.emacs).
Esc-x spell-word to check the spelling of the
word on which you're currently sitting
.emacs file:
Ctrl-x ( to start recording.
Ctrl-x ) to end recording.
Esc-x name-last-kbd-macro or just Esc-x
name to assign a name to the macro.
.emacs file.
Esc-x insert-kbd-macro
\renewcommand{\familydefault}{cmss}
\usepackage{geometry} (e.g., use
\geometry{margin=1in})
natbib for bibliographies
colortbl package for creating color tables
\newcommand\R{{I\!\!R}}
\usepackage{times} to use a times font that is
generally rendered more nicely than computer modern.
ps2pdf gets the fonts mucked up.
One way to avoid this:
latex myfile.tex dvips -Ppdf -t letter -G0 myfile.dvi ps2pdf myfile.ps
dvipdfm will also create a PDF file from a dvi file with
the correct fonts. For example,
latex myfile.tex dvipdfm -p letter myfile.dviSpecifying the "letter" papersize is important because the default may be a4.
dvipdf, the pdf file looks awful
in the reader but prints okay; dvipdfm
(free to download) gets around this.
~ririzarr/bin/mydvipdf has all
the right options to make high quality pdf from dvi.
Use \usepackage{times} to make sure the
fonts exist.
ghostscript will occasionally automatically rotate
your figure 90 degrees when you convert your document to PDF.
The explanation is a little long but it is considered a
"feature". You can disable this by doing:
setenv GS_OPTIONS "-dAutoRotatePages=/None"at the shell (or the bash equivalent).
texi2dvi --pdf to include png files in latex
documents. (See the vignettes in Rafael's packages.)
\renewcommand{\arraystretch}{1.3}
\renewcommand{\tabcolsep}{12pt}
options(show.signif.stars=FALSE), preferably in
your .Rprofile (see more about that file below).
expand.grid is really handy if you need to plot a
2D function using image.
any and all are useful (e.g.,
any(is.na(mydata$age)))
lapply,
sapply, and tapply intimately.
.Rprofile can be used to load up packages
when starting R. For example, it might contain:
options(defaultPackages = c(getOption("defaultPackages"), "foreign", "MASS"))
You can put a .Rprofile file in your home directory
and others in certain working directories. If one exists in a
working directory, it's used in place of your main one;
otherwise, the main one is used.
help(plotmath) contains examples of
mathematical symbols you can use in R. Here's a really
complicated example:
plot(rnorm(100),rnorm(100),xlab=expression(hat(mu)[0]), ylab=expression(alpha^beta),
main=expression(paste("Plot of ", alpha^beta, " versus ", hat(mu)[0])))
Esc-w to copy within emacs, Alt-tab to switch to
your R window, and then Ctrl-y to yank/paste
into R.
options("scipen") to some positive number to
penalize scientific notation. For example, put
options(scipen=4) in your
.Rprofile
stopifnot() is useful for self-documenting
code.
summary()
function, the function summary.myclass shouldn't
print anything, but rather should return an object of class
"summary.myclass". You should then make another
function print.summary.myclass() which prints a
summary of that.
gc() to determine how much memory R is taking
up. Use object.size() to detemine the amount of
memory taken up by particular objects in your workspace.
memory.profile() is useful sometimes to find out how much
memory is being used by different types of objects.
str() to get a compact display of the internal
structure of a complex object.
wc -w
to count the number of words.
[ Unix/Linux | Emacs | LaTeX | R | Other ] | Last modified: Wed Apr 15 23:00:36 2009 |