Monday, May 10, 2010

Abbreviations of R Commands Explained: 150+ R Abbreviations

The R programming language includes many abbreviations. Abbreviations exist in function names, argument names, and allowed values for arguments. This post expands on over 150 R abbreviations with the aim of making it easier for users new to R who are trying to memorise R commands.

Context

Abbreviations save time when typing and can make for less cumbersome code. However, abbreviations often make it more difficult to remember a command. This is especially true when the user does not know what the abbreviation stands for.

R has been developed by a group of technical experts with backgrounds in Linux and Unix, mathematics, statistics, and statistical computing. With gaining popularity, R is now being used by people with little to none of this background. Abbreviations which are intuitive to the experts are not necessarily intuitive to this broader audience. The R help system does a reasonable job of explaining the abbreviations in R. However, I thought it would be useful to write a post listing some of the common abbreviations along with the expansion of the abbreviation. Whereas R sometimes errs on the side of assuming expertise, I thought I'd err on the side of assuming naivety. Thus, the table includes many abbreviations which are probably obvious to most readers.

Table of R Commands

R CommandAbbreviation ExpandedCommentsType
ls[L]i[S]t objectscommon command in Unix-like operating systemsBasics
rm[R]e[M]ove objectscommon command in Unix-like operating systemsBasics
str[STR]uctureBasics
unz[UNZ]ipBasics
getwd[GET] [W]orking [D]irectoryBasics
dir[DIR]ectoryBasics
sprintf[PRINT] [F]ormattedS for String of Silently?Basics
c[C]ombine valuesBasics
regexpr[REG]ular [EXPR]essionWhy "regular"? See regular sets, regular languageStrings
diag[DIAG]onal values of a matrixBasics
col[COL]umnBasics
lapply[APPLY] to each element of a list or vector and return a [L]istL is for ListBasics
sapply[APPLY ]to each element of a list or vector and attempt to [S]implify the returned object to a vectorS is for SimplifyBasics
mapply[M]ultivariate version of s[APPLY]Basics
tapply[T]able [APPLY] function to sets of values as defined by an indexBasics
apply[APPLY] function to sets of values as defined by an indexBasics
MARGIN = 1 or 2 in applyrows [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 dataBasics
rle[R]un [L]ength [E]ncodingBasics
ftable[F]ormat [TABLE]Basics
xtabsCross (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 anotherBasics
xtable[TABLE] of the object [X]Basics
formatC[FORMAT] using [C] style formatsi.e., [C] the programming languageBasics
Sweave[WEAVE] [S] code in a LaTeX documentThe R Programming language is a dialect of SBasics
cor[COR]relationanalyses
ancova[AN]alysis [O]f [COVA]rianceanalyses
manova[M]ultivariate [AN]alysis [O]f [COVA]rianceanalyses
aov[A]nalysis [O]f [V]arianceanalyses
TukeyHSD[T]ukey's [H]onestly [S]ignificant [D]ifferenceanalyses
hclust[H]ierarchical [CLUST]er analysisanalyses
cmdscale[C]lassical metric [M]ulti[D]imensional [SCAL]inganalyses
factanal[FACT]or [ANAL]ysisanalyses
princomp[PRIN]cipal [COMP]onents analysisanalyses
prcomp[PR]incipal [COMP]onents analysisanalyses
lme[L]inear [M]ixed [E]ffects modelanalyses
resid[RESID]ualsmodels
ranef[RAN]dom [EF]fectsmodels
anova[AN]alysis [O]f [VA]riancemodels
fixef[FIX]ed [EF]ffectsmodels
vcov[V]ariance-[COV]ariance matrixmodels
logLik[LOG] [LIK]elihoodmodels
BIC[B]ayesian [I]nformation [C]riteriamodels
mcmcsamp[M]arkov [Chain] [Monte] [C]arlo [SAMP]lingmodels
eval[EVAL]uate an R expressionBasics
catcon[CAT]enatestandard Unix commandBasics
aproposSearch 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 formati.e., in each row of the data commas separate values for each variableBasics
read.fwf[READ] a file in [F]ixed [W]idth [F]ormatBasics
seqGenerate [SEQ]uenceBasics
rep[REP]licate values of xperhaps also [REP]eatBasics
dim[DIM]ension of an objectTypically, number of rows and columns in a matrixBasics
gl[G]enerate factor [L]evelsBasics
rbind[BIND] [R]ows togetherBasics
cbind[BIND] [C]olumns togetherBasics
is.na[IS] [N]ot [A]vailableBasics
nrow[N]umber of [ROW]sBasics
ncol[N]umber of [COL]umnsBasics
attr[ATTR]ibuteBasics
rev[REV]erseBasics
diff[DIFF]erence between x and a lag of xMath
prod[PROD]uctMath
var[VAR]ianceMath
sd[S]tandard [D]eviationMath
cumsum[CUM]ulative [SUM]Math
cumprod[CUM]ulative [PROD]uctMath
setdiff[DIFF]erence between two [SET]sMath
intersect[INTERSECT]ionMath
Re[RE]al part of a numberMath
Im[IM]aginary part of a numberMath
Mod[MOD]ulo opertionremainder of division of one number by anotherMath
t[T]ranspose of a vector or matrixMath
substrReturn [SUBSTR]ingStrings
strsplit[SPLIT] a [STR]ing vectorStrings
grep[G]lobal / [R]egular [E]xpression / [P]rintEtymology based on text editor instructions in programs such as edStrings
sub[SUB]stitute identified pattern found in stringStrings
gsub[G]lobal [SUB]stitute identified pattern found in stringStrings
pmatch[P]artial string [MATCH]ingStrings
nchar[N]umber of [CHAR]acters in a stringStrings
ps.options[OPTIONS] for [P]ost-[S]criptGraphic Devices
win.metafile[WIN]dows [METAFILE] graphicGraphic Devices
dev.off[DEV]ice [OFF]Graphic Devices
dev.cur[CUR]rent [DEV]iceGraphic Devices
dev.set[SET] the current [DEV]iceGraphic Devices
hist[HIST]ogrambase graphics
pie[PIE] Chartbase graphics
coplot[CO]nditioning [PLOT]base graphics
matplot[PLOT] colums of [MAT]ricesbase graphics
assocplot[ASSOC]iation [PLOT]base graphics
plot.ts[PLOT] [T]ime [S]eriesbase graphics
qqnorm[Quantile]-[Q]uantile [P]lot based on normal distributionbase graphics
persp[PERSP]ective [P]lotbase graphics
xlim[LIM]it of the [X] axisbase graphics parameter
ylim[LIM]it of the [Y] axisbase graphics parameter
xlab[LAB]el for the [X] axisbase graphics parameter
ylab[LAB]el for the [Y] axisbase graphics parameter
main[MAIN] title for the plotbase graphics parameter
sub[SUB] title for the plotbase graphics parameter
mtext[M]argin [TEXT]base graphics parameter
abline[LINE] on plot often of the form y = [A] + [B] xbase graphics parameter
h argument in abline[H]orizontal linebase graphics parameter
v argument in abline[V]ertical linebase graphics parameter
parGraphics [PAR]ameterbase graphics parameter
adj[ADJ]ust text [J]ustificationbase graphics parameter
bg[B]ack[G]round colourbase graphics parameter
bty[B]ox [TY]pebase graphics parameter
cex[C]haracter [EX]tension or [EX]pansion of plotting objectsbase graphics parameter
cex.sub[C]haracter [EX]tension or [EX]pansion of [SUB]titlebase graphics parameter
cex.axis[C]haracter [EX]tension or [EX]pansion of [AXIS] annotationbase graphics parameter
cex.lab[C]haracter [EX]tension or [EX]pansion X and Y [LAB]elsbase graphics parameter
cex.main[C]haracter [EX]tension or [EX]pansion of [MAIN] titlebase graphics parameter
colDefault plotting [COL]ourbase graphics parameter
las[L]abel of [A]xis [S]tylebase graphics parameter
lty[L]ine [TY]pebase graphics parameter
lwd[L]ine [W]i[D]thbase graphics parameter
mar[MAR]gin widthbase graphics parameter
mfgNext [G]raph for [M]atrix of [F]iguresbase graphics parameter
mfcol[M]atrix of [F]igures entered [COL]umn-wisebase graphics parameter
mfrow[M]atrix of [F]igures entered [ROW]-wisebase graphics parameter
pch[P]lotting [CH]aracterbase graphics parameter
ps[P]oint [S]ize of textPoint is a printing measurementbase graphics parameter
pty[P]lot region [TY]pebase graphics parameter
tckLength of [T]i[CK] marksbase graphics parameter
tcl[T]i[C]k mark lengthbase graphics parameter
xaxs[X] [AX]is [S]tylebase graphics parameter
yaxs[Y] [AX]is [S]tylebase graphics parameter
xaxt[X] [AX]is [T]ypebase graphics parameter
yaxt[Y] [AX]is [T]ypebase graphics parameter
asp[ASP]ect ratiobase graphics parameter
xyplot[X] [Y] [PLOT][X] for horizontal axis; [Y] for vertical axislattice
bwplot[B]ox and [W]hisker plotlattice
qq[Q]uantile-[Quantile] plot'lattice
splom[S]catter[PLO]t [M]atrixlattice
optim[OPTIM]isationanalyses
lm[L]inear [M]odelanalyses
glm[G]eneralised [L]inear [M]odelanalyses
nls[N]onlinear [L]east [S]quare parameter esetimationanalyses
loess[LO]cally [E]stimated [S]catterplot [S]moothinganalyses
prop.test[TEST] null hypothesis that [PROP]ortions in several gropus are the sameanalyses
rnorm[R]andom number drawn from [NORM]al distributiondistributions
dnorm[D]ensity of a given quantile in a [NORM]al distributiondistributions
pnorm[D]istribution function for [NORM]al distribution returning cumulaive [P]robabilitydistributions
qnorm[Q]uantile function based on [NORM]al distributiondistributions
rexp[R]andom number generation from [EXP]onential distributiondistributions
rgamma[R]andom number generation from [GAMMA] distributiondistributions
rpois[R]andom number generation from [POIS]on distributiondistributions
rweibull[R]andom number generation from [WEIBULL] distributiondistributions
rcauchy[R]andom number generation from [CAUCHY] distributiondistributions
rbeta[R]andom number generation from [BETA] distributiondistributions
rt[R]andom number generation from [t] distributiondistributions
rf[R]andom number generation from [F] distributionF for Ronald [F]isherdistributions
rchisq[R]andom number generation from [CHI] [SQ]uare distributiondistributions
rbinom[R]andom number generation from [BINOM]ial distributiondistributions
rgeom[R]andom number generation from [EXP]onential distributiondistributions
rhyper[R]andom number generation from [HYPER]geometric distributiondistributions
rlogis[R]andom number generation from [LOGIS]tic distributiondistributions
rlnorm[R]andom number generation from [L]og [NOR]mal distributiondistributions
rnbinom[R]andom number generation from [N]egative [BINOM]ial distributiondistributions
runif[R]andom number generation from [UNIF]orm distributiondistributions
rwilcox[R]andom number generation from [WILCOX]on distributiondistributions
ggplot[G]rammar of [G]raphics [PLOT]See Leland Wilkinson (1999)Graphics
x as argument[X] is common letter for unknown variable in mathBasics
FUN as argument[FUN]ctionBasics
pos as argument[POS]itionBasics
lib.loc in library[LIB]rary folder [LOC]ationBasics
sep as argument[SEP]erator characterBasics
comment.char in read.table[COMMENT] [CHAR]acter(s)Basics
I[I]nhibit [I]nterpretationBasics
T value[T]rueBasics
F value[F]alseBasics
na.rm[N]ot [A]vailable values are to be [R]e[M]ovedBasics
fivenum[FIVE] [NUM]ber summaryBasics
IQR[I]nter [Q]uartile [R]angeBasics
coefModel [COEF]ficientsBasics
distCompute [DIST]ance matrixBasics
df[D]egrees of [F]reedomBasics
mad[M]edian [A]bsolute [D]eviationBasics
sinkDivert 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 SBasics
CRAN[C]omprehensive [R] [A]rchive [N]etworkBasics

Concluding Comments

I thank Tom Short for his R reference Card which provided some inspiration for a starting list of R commands. Feel free to reproduce or adapt this table elsewhere. For example, perhaps it could be included in an R Wiki with additional entries. If you spot an error in the table, let me know in the comments of this post.

I might expand the table in the future. At the moment, it's mainly function names with not many arguments or values of arguments. I also haven't put much time into grouping and ordering the functions.

No comments:

Post a Comment