The R book: Essentials of the R Language Flashcards

1
Q

logs with base 10

A

log10()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Enter the numbers from the keyboard one at a time

A

scan()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Named Elements within vectors

A

names(counts) <- 0:8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

pmax?

A

vector, of length equal to the longest of x, y, z, containing the maximum of x, y or z for the ith position in each

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

if names(data) is “Growth.rate” “Water” “Detergent” “Dephnia”, how to find the mean growth rate for each detergent

A

tapply(Growth.rate, Detergent, mean)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Calculate the median growth rate for water type and daphnia clone

A

tapply(Growth.rate, list(Water, Daphnia), median)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

with function

A

evaluates an R expression in an environment constructed from data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

To see the names of the dataframes in the build-in package called datasets

A

data()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

See all available data sets (including those in the installed packages)

A

data(package = .packages(all.available = TRUE))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

subscripts on lists

A

double square

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

reverse sort on vector x

A

rev(sort(x))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Subscripts for values bigger than 5

A

which(y>5)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Every 25th value in a 100-long vector of normal random number with mean value 100 and standard deviation 10

A

xv <- rnorm(1000, 100, 10)

xv[seq(25, length(xv),25)]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Find logical combinations of &

A

outer(x, x, “&”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

repeat function

A

rep(1:4, each = 2, times = 3)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

one 1, two 2s, three 3s, and four 4s

A

rep(1:4, 1:4)

17
Q

Syntamx of gl (‘generate levels’)

A

gl(‘up to’, ‘with repeats of’, ‘to total length’)

18
Q

Text for the factors levels, rather than numbers

A

gl(3, 2, 24, labels = c(“A”, “B”, “C”))

19
Q

Create a sequence with the same length as vector x

A

seq(88, 50, along = x)

20
Q

sequence(c(5, 2, 4))

A

1 2 3 4 5 1 2 1 2 3 4