Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

1.6.9.4: Most essential R commands

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

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

head()

Show first rows of data frame

help()

Help

hist()

Histogram

ifelse()

Vectorized condition

legend()

Add legend to the plot

library()

Load the installed package

length()

Length (number of items) of variable

list()

Make list object

lines()

Add lines to the plot

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.table()

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

Add text to the plot

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.

Support Center

How can we help?