Data selection and manipulation Flashcards

1
Q

which.max(x)

A

returns the index of the greatest element of x

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

which.min(x)

A

returns the index of the smallest element of x

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

rev(x)

A

reverses the elements of x

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

sort(x)

A

sorts the elements of x in increasing order; to sort in decreasing
order: rev(sort(x))

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

cut(x,breaks)

A

divides x into intervals (factors); breaks is the number

of cut intervals or a vector of cut points

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

match(x, y)

A

returns a vector of the same length than x with the elements

of x which are in y (NA otherwise)

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

which(x == a)

A

returns a vector of the indices of x if the comparison op-
eration is true (TRUE), in this example the values of i for which x[i] == a (the argument of this function must be a variable of mode logi- cal)

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

choose(n, k)

A

computes the combinations of k events among n repetitions = n!/[(n − k)!k!]

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

na.omit(x)

A

suppresses the observations with missing data (NA) (sup- presses the corresponding line if x is a matrix or a data frame)

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

na.fail(x)

A

returns an error message if x contains at least one NA

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

unique(x)

A

if x is a vector or a data frame, returns a similar object but with the duplicate elements suppressed

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

table(x)

A

returns a table with the numbers of the differents values of x (typically for integers or factors)

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

subset(x, …)

A

returns a selection of x with respect to criteria (…, typically comparisons: x$V1 < 10); if x is a data frame, the option select gives the variables to be kept or dropped using a minus sign

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

sample(x, size)

A

resample randomly and without replacement size ele- ments in the vector x, the option replace = TRUE allows to resample with replacement

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

prop.table(x,margin=)

A

table entries as fraction of marginal table

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

with(data, expr, …)

A

Evaluate an R expression in an environment constructed from data, possibly modifying the original data.