R Command Abbreviations by Jeromy Anglim

May 10th, 2010 Minzhao No comments

From: http://jeromyanglim.blogspot.com/2010/05/abbreviations-of-r-commands-explained.html

R Command Abbreviation Expanded Comments Type
ls [L]i[S]t objects common command in Unix-like operating systems Basics
rm [R]e[M]ove objects common command in Unix-like operating systems Basics
str [STR]ucture Basics
unz [UNZ]ip Basics
getwd [GET] [W]orking [D]irectory Basics
dir [DIR]ectory Basics
sprintf [PRINT] [F]ormatted S for String of Silently? Basics
c [C]ombine values Basics
regexpr [REG]ular [EXPR]ession Why “regular”? See regular sets, regular language Strings
diag [DIAG]onal values of a matrix Basics
col [COL]umn Basics
lapply [APPLY] to each element of a list or vector and return a [L]ist L is for List Basics
sapply [APPLY ]to each element of a list or vector and attempt to [S]implify the returned object to a vector S is for Simplify Basics
mapply [M]ultivariate version of s[APPLY] Basics
tapply [T]able [APPLY] function to sets of values as defined by an index Basics
apply [APPLY] function to sets of values as defined by an index Basics
MARGIN = 1 or 2 in apply rows [1] come before columns [2] e.g., a 2 x 3 matrix has 2 rows and 3 columns (note: row count is stated first) Basics
rmvnorm [R]andom number generator for [M]ulti[V]ariate [NORM]al data Basics
rle [R]un [L]ength [E]ncoding Basics
ftable [F]ormat [TABLE] Basics
xtabs Cross (i.e., [X]) [TAB]ulation [X] is the symbol of a cross; [X] is sometimes spoken as “by”. Cross-tabulating means to cross one variable with another Basics
xtable [TABLE] of the object [X] Basics
formatC [FORMAT] using [C] style formats i.e., [C] the programming language Basics
Sweave [WEAVE] [S] code in a LaTeX document The R Programming language is a dialect of S Basics
cor [COR]relation analyses
ancova [AN]alysis [O]f [COVA]riance analyses
manova [M]ultivariate [AN]alysis [O]f [COVA]riance analyses
aov [A]nalysis [O]f [V]ariance analyses
TukeyHSD [T]ukey’s [H]onestly [S]ignificant [D]ifference analyses
hclust [H]ierarchical [CLUST]er analysis analyses
cmdscale [C]lassical metric [M]ulti[D]imensional [SCAL]ing analyses
factanal [FACT]or [ANAL]ysis analyses
princomp [PRIN]cipal [COMP]onents analysis analyses
prcomp [PR]incipal [COMP]onents analysis analyses
lme [L]inear [M]ixed [E]ffects model analyses
resid [RESID]uals models
ranef [RAN]dom [EF]fects models
anova [AN]alysis [O]f [VA]riance models
fixef [FIX]ed [EF]ffects models
vcov [V]ariance-[COV]ariance matrix models
logLik [LOG] [LIK]elihood models
BIC [B]ayesian [I]nformation [C]riteria models
mcmcsamp [M]arkov [Chain] [Monte] [C]arlo [SAMP]ling models
eval [EVAL]uate an R expression Basics
cat con[CAT]enate standard Unix command Basics
apropos Search documentation for a purpose or on a topic (i.e., [APROPOS]) Unix command for search documentation; Basics
read.csv [READ] a file in [C]omma [S]eperated [V]alues format i.e., in each row of the data commas separate values for each variable Basics
read.fwf [READ] a file in [F]ixed [W]idth [F]ormat Basics
seq Generate [SEQ]uence Basics
rep [REP]licate values of x perhaps also [REP]eat Basics
dim [DIM]ension of an object Typically, number of rows and columns in a matrix Basics
gl [G]enerate factor [L]evels Basics
rbind [BIND] [R]ows together Basics
cbind [BIND] [C]olumns together Basics
is.na [IS] [N]ot [A]vailable Basics
nrow [N]umber of [ROW]s Basics
ncol [N]umber of [COL]umns Basics
attr [ATTR]ibute Basics
rev [REV]erse Basics
diff [DIFF]erence between x and a lag of x Math
prod [PROD]uct Math
var [VAR]iance Math
sd [S]tandard [D]eviation Math
cumsum [CUM]ulative [SUM] Math
cumprod [CUM]ulative [PROD]uct Math
setdiff [DIFF]erence between two [SET]s Math
intersect [INTERSECT]ion Math
Re [RE]al part of a number Math
Im [IM]aginary part of a number Math
Mod [MOD]ulo opertion remainder of division of one number by another Math
t [T]ranspose of a vector or matrix Math
substr Return [SUBSTR]ing Strings
strsplit [SPLIT] a [STR]ing vector Strings
grep [G]lobal / [R]egular [E]xpression / [P]rint Etymology based on text editor instructions in programs such as ed Strings
sub [SUB]stitute identified pattern found in string Strings
gsub [G]lobal [SUB]stitute identified pattern found in string Strings
pmatch [P]artial string [MATCH]ing Strings
nchar [N]umber of [CHAR]acters in a string Strings
ps.options [OPTIONS] for [P]ost-[S]cript Graphic Devices
win.metafile [WIN]dows [METAFILE] graphic Graphic Devices
dev.off [DEV]ice [OFF] Graphic Devices
dev.cur [CUR]rent [DEV]ice Graphic Devices
dev.set [SET] the current [DEV]ice Graphic Devices
hist [HIST]ogram base graphics
pie [PIE] Chart base graphics
coplot [CO]nditioning [PLOT] base graphics
matplot [PLOT] colums of [MAT]rices base graphics
assocplot [ASSOC]iation [PLOT] base graphics
plot.ts [PLOT] [T]ime [S]eries base graphics
qqnorm [Quantile]-[Q]uantile [P]lot based on normal distribution base graphics
persp [PERSP]ective [P]lot base graphics
xlim [LIM]it of the [X] axis base graphics parameter
ylim [LIM]it of the [Y] axis base graphics parameter
xlab [LAB]el for the [X] axis base graphics parameter
ylab [LAB]el for the [Y] axis base graphics parameter
main [MAIN] title for the plot base graphics parameter
sub [SUB] title for the plot base graphics parameter
mtext [M]argin [TEXT] base graphics parameter
abline [LINE] on plot often of the form y = [A] + [B] x base graphics parameter
h argument in abline [H]orizontal line base graphics parameter
v argument in abline [V]ertical line base graphics parameter
par Graphics [PAR]ameter base graphics parameter
adj [ADJ]ust text [J]ustification base graphics parameter
bg [B]ack[G]round colour base graphics parameter
bty [B]ox [TY]pe base graphics parameter
cex [C]haracter [EX]tension or [EX]pansion of plotting objects base graphics parameter
cex.sub [C]haracter [EX]tension or [EX]pansion of [SUB]title base graphics parameter
cex.axis [C]haracter [EX]tension or [EX]pansion of [AXIS] annotation base graphics parameter
cex.lab [C]haracter [EX]tension or [EX]pansion X and Y [LAB]els base graphics parameter
cex.main [C]haracter [EX]tension or [EX]pansion of [MAIN] title base graphics parameter
col Default plotting [COL]our base graphics parameter
las [L]abel of [A]xis [S]tyle base graphics parameter
lty [L]ine [TY]pe base graphics parameter
lwd [L]ine [W]i[D]th base graphics parameter
mar [MAR]gin width base graphics parameter
mfg Next [G]raph for [M]atrix of [F]igures base graphics parameter
mfcol [M]atrix of [F]igures entered [COL]umn-wise base graphics parameter
mfrow [M]atrix of [F]igures entered [ROW]-wise base graphics parameter
pch [P]lotting [CH]aracter base graphics parameter
ps [P]oint [S]ize of text Point is a printing measurement base graphics parameter
pty [P]lot region [TY]pe base graphics parameter
tck Length of [T]i[CK] marks base graphics parameter
tcl [T]i[C]k mark length base graphics parameter
xaxs [X] [AX]is [S]tyle base graphics parameter
yaxs [Y] [AX]is [S]tyle base graphics parameter
xaxt [X] [AX]is [T]ype base graphics parameter
yaxt [Y] [AX]is [T]ype base graphics parameter
asp [ASP]ect ratio base graphics parameter
xyplot [X] [Y] [PLOT] [X] for horizontal axis; [Y] for vertical axis lattice
bwplot [B]ox and [W]hisker plot lattice
qq [Q]uantile-[Quantile] plot’ lattice
splom [S]catter[PLO]t [M]atrix lattice
optim [OPTIM]isation analyses
lm [L]inear [M]odel analyses
glm [G]eneralised [L]inear [M]odel analyses
nls [N]onlinear [L]east [S]quare parameter esetimation analyses
loess [LO]cally [E]stimated [S]catterplot [S]moothing analyses
prop.test [TEST] null hypothesis that [PROP]ortions in several gropus are the same analyses
rnorm [R]andom number drawn from [NORM]al distribution distributions
dnorm [D]ensity of a given quantile in a [NORM]al distribution distributions
pnorm [D]istribution function for [NORM]al distribution returning cumulaive [P]robability distributions
qnorm [Q]uantile function based on [NORM]al distribution distributions
rexp [R]andom number generation from [EXP]onential distribution distributions
rgamma [R]andom number generation from [GAMMA] distribution distributions
rpois [R]andom number generation from [POIS]on distribution distributions
rweibull [R]andom number generation from [WEIBULL] distribution distributions
rcauchy [R]andom number generation from [CAUCHY] distribution distributions
rbeta [R]andom number generation from [BETA] distribution distributions
rt [R]andom number generation from [t] distribution distributions
rf [R]andom number generation from [F] distribution F for Ronald [F]isher distributions
rchisq [R]andom number generation from [CHI] [SQ]uare distribution distributions
rbinom [R]andom number generation from [BINOM]ial distribution distributions
rgeom [R]andom number generation from [EXP]onential distribution distributions
rhyper [R]andom number generation from [HYPER]geometric distribution distributions
rlogis [R]andom number generation from [LOGIS]tic distribution distributions
rlnorm [R]andom number generation from [L]og [NOR]mal distribution distributions
rnbinom [R]andom number generation from [N]egative [BINOM]ial distribution distributions
runif [R]andom number generation from [UNIF]orm distribution distributions
rwilcox [R]andom number generation from [WILCOX]on distribution distributions
ggplot [G]rammar of [G]raphics [PLOT] See Leland Wilkinson (1999) Graphics
x as argument [X] is common letter for unknown variable in math Basics
FUN as argument [FUN]ction Basics
pos as argument [POS]ition Basics
lib.loc in library [LIB]rary folder [LOC]ation Basics
sep as argument [SEP]erator character Basics
comment.char in read.table [COMMENT] [CHAR]acter(s) Basics
I [I]nhibit [I]nterpretation Basics
T value [T]rue Basics
F value [F]alse Basics
na.rm [N]ot [A]vailable values are to be [R]e[M]oved Basics
fivenum [FIVE] [NUM]ber summary Basics
IQR [I]nter [Q]uartile [R]ange Basics
coef Model [COEF]ficients Basics
dist Compute [DIST]ance matrix Basics
df [D]egrees of [F]reedom Basics
mad [M]edian [A]bsolute [D]eviation Basics
sink Divert R output to a connection (i.e., like connecting a pipe to a [SINK]) Basics
eol in write.table [End] [O]f [L]ine character(s) Basics
R [R]oss Ihaka and [R]obert Gentleman or [R] is letter before S Basics
CRAN [C]omprehensive [R] [A]rchive [N]etwork Basics
Categories: R Tags:

Using LaTeX to Split PDF Files

May 8th, 2010 Minzhao No comments

Motivation

LaTeX is not only a tool to type literatures, but also a tool to do other things. For example, if I wanna extract one or several pages from one or more pdf files, I could use that with some pdf editor , but by some packages in LaTeX, you could also make that.

Usage

Suppose your source pdf is source.pdf, you wanna draw the 2nd and 4th page from that, by

\usepackage{pdfpages}
\includepdf[page={2,4}]{source}

pdflatex -> voila, here you are.

Reference

For more details, see pdfpages package.

Categories: LaTeX Tags: , ,

firemacs by Kazu Yamamoto ( a emacs(vi)-like plugin for firefox)

May 2nd, 2010 Minzhao No comments

Introduction

This plugin helps you browse website via firefox without moving your hands up and down. That does not mean you could discard your mouse, but if combined with thinkpad little red point on your keyboard, it’s pretty awesome that you could leave your cordless mouse alone.

Basic Usage

My basic use is :

  • h : go to previous tab
  • l : go to next tab
  • j : scroll up
  • k : scroll down
  • b: page up
  • u: page down
  • C-v: page down
  • M-v: page up
  • C-b: go to previous
  • C-f: go to next tab
  • C-n: go to next line
  • C-p: go to previous line
  • C-x k: kill current tab
  • C-s: search
  • C-w: cut
  • C-y: paste
  • M-w: copy
  • C-a: go to the head of current line
Categories: Emacs, Web Tags: , ,

Recent-jump.el for Emacs by ChunYe Wang

April 27th, 2010 Minzhao No comments

Reference: Written by ChunYe Wang, here’s the file I got originally.

Motivation

recent-jump.el written by ChunYe Wang,  is such a implementation for Emacs that it helps you to jump where you visit recently. Sometimes it’s annoying to move up and down while revising your papers, usually I forgot to mention something in the previous paragraph, or have to copy some code from other buffer.

I used to play ido.el and ibuffer.el , which are extremely useful and helpful to switch between buffers. Now combined with recent-jump.el, you could not only jump between lines, but jump between buffers as well, even the very point you just edit in the last several buffer. Here’s how to do it.

Download

borrowed from bigFang

Usage

  1. installation:
    put recent-jump.el in your emacs load path.
  2. configuration:
    (setq recent-jump-threshold 4)
    (setq recent-jump-ring-length 10)
    (global-set-key (kbd "C-o") 'recent-jump-jump-backward)
    (global-set-key (kbd "M-o") 'recent-jump-jump-forward)
    (require 'recent-jump)

    even if you do not know anything about emacs lisp language, it ’s still quite easy to understand what those codes mean. Use C-o to jump backward, and M-o to jump forward.

    Enjoy.

Categories: Emacs Tags:

Calc2LaTeX Plug-in for Making LaTeX Tables

April 27th, 2010 Minzhao No comments

Motivation

It’s really disgusting to make complicated tables when you are typing LaTeX, here’s one method helping you to get LaTeX code for whatever table you want.

The basic idea is to take advantage of those WYSIWYG software like Excel or OpenOffice Spreadsheet. There’s a plug-in called Excel2Latex which could transform your excel table into LaTeX code. While for free OpenOffice Spreadsheet, the calc2latex plug-in is quite helpful. By that, you will no longer worry about how to make multicolumn, multirow, all kinds of weird tables in LaTeX.

Download

Download from this url.

Usage

  1. after installation
  2. make your table in OpenOffice Spreadsheet
  3. mark your table and click tools, ‘Macros’ -> ‘run Macro’
  4. choose ‘My Macros’,-> ‘Calc2LaTeX’ -> ‘Calc2LaTeX’ -> Main -> Run
  5. choose your setup

then you could copy the results into your LaTeX file. Easy~

Categories: LaTeX Tags: , ,

Get BibTeX from Google Scholar

April 15th, 2010 Minzhao No comments

1. go to www.google.com/scholar.

2. scholar preference

3.Bibliography Manager: choose BibTeX

4. search for paper and click ‘ import into BibTeX’

5. copy that in your bib file.

But the problem is that there’s still some error in the bibtex from google scholar, for example ,

http://scholar.google.com/scholar.bib?q=info:Kb5Zq_JwPi0J:scholar.google.com/&output=citation&hl=en&as_sdt=40000&ct=citation&cd=2

@article{alan2002categorical,
  title={{Categorical data analysis}},
  author={Alan, A.},
  journal={Editorial John Willey \& Sons},
  year={2002}
}

actually, the author is Dr. Alan Agresti, and the publisher is John Wiley & Sons. Well, anyone has better suggestions?

Categories: Emacs, LaTeX, Study Tags:

A nice ggplot2 web interface by Jeroen Ooms

April 12th, 2010 Minzhao No comments

http://www.yeroon.net/ggplot2/

pretty , just give a try.

Categories: R, Study Tags:

How to add CC license into LaTeX file and how to build LaTeX package

March 29th, 2010 Minzhao No comments

Introduction

This article will introduce how to add CC into \LaTeX file and how to build your own \LaTeX package.

What is CC

CC is short for Creative Commons, which provides various kinds of licenses. Basically, CC license announces some rights reserved or some perticular rights reserved instead of All rights reserved. On their website, you could customize the license you want, just by clicking some buttons. Convenient html code will be produced.

CC license in \LaTeX slides

However, those codes are only for html, in order to embed CC license into \LaTeX slides, usually beamer slides, I found the following historical, ugly, but ready-eat \LaTeX package cclicenses CTAN. Here’s how it works:

put the following code in the preamble,

\usepackage{cclicenses}

then follow the instruction in the help pdf for cclicenses package above.

Fortunately, I found this post by Sebastian Pipping. Here’s the screenshot.

ccbeamer

One thing Sebastian Pipping mentioned is that it’s not a real \LaTeX package, thus to be a legitimate lazy man, I modified his package a little and built this ccbeamer \LaTeX package.

How to make your own \LaTeX package

Referring to this web page, I did as follows:

  1. Rename Sebastian’s ccbeamer.tex to ccbeamer.sty (used to put all your command into .sty file)
  2. For your \TeX distribution, (mine is TeXlive 2009) , find where \LaTeX packages are installed. (mine is usr/local/texlive/2009/texmf-dist/tex/latex)
  3. make directory, and put creative commons and ccbeamer.sty in.
  4. use texhash to refresh your \LaTeX database.

so if you download my modified ccbeamer \LaTeX package, what you need to do is just to extract the zip file into where your \LaTeX packages are installed, and refresh the database, put

\usepackage{ccbeamer}

in your preamble.

For more options, read the ccbeamer.sty file.

Download

Categories: Emacs, Study Tags: , ,

How to establish your own blog

March 29th, 2010 Minzhao No comments

Motivation

In this article, I will give a brief introduction about how to build a blog with WordPress.

What you need and how to do

  • domain
    First you need to register the url you wanna use. For example, my domain is got from www.godaddy.com, just for $1. Godaddy always has some deals and coupons from time to time. The domain, like your home address, should be impressive and easy to remember.

  • host
    Host is like a server, where you put all your website files and data. In order to use WordPress, the host has to support PHP, MySQL and so on. Usually, you could get your host where you get the domain,like Bluehost, Dreamhost, Godaddy and so forth, but basically they are not free. Actually there does exist many free hosting service, which also means less stable and volumn. For example, mine is from 000Webhsot.

  • WordPress
    WordPress is an open source blog publishing application powered by PHP and MySQL which can also be used for content management. It’s free and user-friendly. Actually, you can design your blog, your website, even forum after obtaining host and domain, but I am a lazy man, WordPress is just the tool for me to publish my notes without taking time on css design or whatever, they have a lot of plugins and themes which are extremely useful. I would write an article about recommended WordPress plugins.

How to combine WordPress with your host

  1. Log in your host server, and find CPanel.
  2. Find Software/Service, MySQL
  3. Create new database and user, then right now, you would have

    • database name
    • database username
    • database host (some would give you its own host , otherwise, it’s localhost)
  4. Back to CPanel, and find Files
    Use web file manager or FTP method, to upload WordPress to /publichtml

    • for standard CPanel, you could download WordPress zip or gz file, and upload it directly, then standard CPanel would extract it.
    • for nonstandard CPanel, you could download WordPress zip or gz file on your local desktop, and extract it by yourself, then upload the whole directory onto /publichtml
  5. On your web browser, type in your domain (your website). Voila, here’s your website. If everything is fine, you will be informed that you lack a configuration. Following those clicks, input your database name, username, password, host address( most do not need to change), and so on, then get a temporary password, do remember that, change it later.
  6. Voila, it works.

Categories: Web Tags: , ,