# 1.6.9.4: Most essential R commands

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$

( \newcommand{\kernel}{\mathrm{null}\,}\) $$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\id}{\mathrm{id}}$$

$$\newcommand{\Span}{\mathrm{span}}$$

$$\newcommand{\kernel}{\mathrm{null}\,}$$

$$\newcommand{\range}{\mathrm{range}\,}$$

$$\newcommand{\RealPart}{\mathrm{Re}}$$

$$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$

$$\newcommand{\Argument}{\mathrm{Arg}}$$

$$\newcommand{\norm}[1]{\| #1 \|}$$

$$\newcommand{\inner}[2]{\langle #1, #2 \rangle}$$

$$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

$$\newcommand{\vectorA}[1]{\vec{#1}} % arrow$$

$$\newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow$$

$$\newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vectorC}[1]{\textbf{#1}}$$

$$\newcommand{\vectorD}[1]{\overrightarrow{#1}}$$

$$\newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}}$$

$$\newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}}$$

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

This is the short collection of the most frequently used R commands based on the analysis of almost 500 scripts (Figure 3.4.2). For the longer list, check R reference card attached to this book, or R help and manuals.

?

Help

<-

Assign right to left

[

Select part of object

\$

Call list element by name

abline()

Add the line from linear regression model

aov()

Analysis of variation

as.character()

Convert to text

as.numeric()

Convert to number

as.matrix()

Convert to matrix

boxplot()

Boxplot

c()

Join into vector

cbind()

Join columns into matrix

chisq.test()

Chi-squared test

cor()

Correlation of multiple variables

colSums()

Sum every column

cor.test()

Correlation test

data.frame()

Make data frame

dev.off()

Close current graphic device

dotchart()

Replacement for “pie” chart

example()

Call example of command

factor()

Convert to factor, modify factor

file.show()

Show file from disk

function() ...

Make new function

Show first rows of data frame

help()

Help

hist()

Histogram

ifelse()

Vectorized condition

legend()

library()

length()

Length (number of items) of variable

list()

Make list object

lines()

lm()

Linear model

log()

Natural logarithm

log10()

Decimal logarithm

max()

Maximal value

mean()

Mean

median()

Median

min()

Minimal value

NA

Missed value

na.omit

Skip missing values

names()

Show names of elements

nrow()

How many rows?

order()

Create order of objects

paste()

Concatenate two strings

par()

Set graphic parameters

pdf()

Open PDF device

plot()

Graph

points()

Add points (dots) to the plot

predict()

Predict values

q("no")

Quit R and do not save workspace

qqnorm(); qqline()

Visual check for the normality

rbind()

Join into matrix by rows

Read data file from disk into R

rep()

Repeat

sample()

Random selection

savehistory()

Save history of commands (does not work under macOS GUI)

scale()

Make all variables comparable

sd()

Standard deviation

source()

Run script

str()

Structure of object

summary()

Explain the object, e.g., return main description statistics

t()

Transpose matrix (rotate on right angle)

t.test()

Student test (t-test)

table()

Make contingency table

text()

url.show()

Show the Internet file

wilcox.test()

Wilcoxon test

write.table()

Write to disk

This page titled 1.6.9.4: Most essential R commands is shared under a Public Domain license and was authored, remixed, and/or curated by Alexey Shipunov.