R Functions Flashcards
(55 cards)
1
Q
!
A
NOT
2
Q
c()
A
Combine
3
Q
length()
A
Tells length
4
Q
head()
A
first six lines
5
Q
tail()
A
last few lines
6
Q
names()
A
returns column names
7
Q
rownames()
A
returns row names
8
Q
colnames()
A
returns column
9
Q
dim()
A
returns dimensions
10
Q
sort()
A
sorts vector in ascending or descending order
11
Q
nrow()
A
counts the number of rows
12
Q
%in%
A
which A are in B (gives TRUE or FALSE)
13
Q
-
A
excludes variable
14
Q
unique()
A
gives unique values
15
Q
str()
A
gives the structure
16
Q
system()
A
run basic commands
17
Q
summary()
A
returns summary
18
Q
rep()
A
replicate of values
19
Q
~
A
“as a function of”
20
Q
seq()
A
sequence
21
Q
installed.packages()
A
already installed paackages
22
Q
install.packages
A
install packages in ‘’
23
Q
sum()
A
adds
24
Q
sqrt()
A
square root
25
%%
remainder
26
mean()
mean
27
min()
minimum
28
max()
maximum
29
median()
median
30
var()
variance
31
sd()
standard deviation
32
quantile()
sample quantiles based on probabilities
33
prod()
returns product
34
round()
rounds numbers based on decimal point
35
setwd()
sets working directory
36
getwd()
outputs working directory
37
list.files()
finds files based on path
38
set.seed()
number to initiate the pseudorandom number generator
39
sample()
sample from a vector
40
for(xinY){}
for loop to cycle through commands
41
if(x==TRUE){}
if (x) is TRUE then do whatever is inside brackets
42
else{}
if whatever inside if statement is FALSE then do ...
43
dev.new()
opens a new window
44
dev.off()
shuts off connection to file
45
plot()
plots your data
46
points()
adds points to plot
47
legend()
adds a legend
48
par()
changes parameters
49
pdf()
creates a pdf of Plot
50
stripchart()
gives stripchart of raw data
51
hist()
histogram
52
boxplot()
boxplot
53
mtext()
adds text to margins
54
abline()
y=mx+b
55
layout()
sets up a figure canvas up to 4 panels