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 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 |
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