Chapters 1&2 Flashcards

1
Q

What does the rev command do in R?(1)

A

Reverses the order of the vector.

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

What does the sort command do in R?(1)

A

It arranges the vector into either numerical order ascending or alphabetically for character vectors.

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

What does the sum command do in R?(1)

A

Adds the vector constituents.

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

What does the unique command do in R?(1)

A

Denotes all elements of the vector which are unique ie vector_1= c(2, 3, 3, 4, 4 ,4) Unique elements would be 2, 3 ,4.

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

What does the which command do in R?(1)

A

Gives index/indices of particular elements ie which (vector_1==2) [1]=1 as only 2 in vector_1 is equal and is the first value in the vector hence is number 1.

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

If A is a logical vector, A=TRUE, what would !A be read as?

A

Read as ‘Not A’ therefore !A=FALSE.

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

How do you use logical vectors to extract information?(1)

A

By setting a logical vector and applying it to another vector you can bring out all elements of the vector to which the logical vector are true (see pg.11 notes for example).

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

What would happen if you summed a logical vector?(1)

A

It would give you the total number of true vectors.

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

What would happen if you summed the logic vector of another vector?(1)

A

It would sum the values for which have came out of the logic vector applied to the original vector.

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

How would you extract the xth smallest value from a vector?(1)

A

sort(x[x]) note different from doing sort(x) then x[97]! (Made this error in exercise 2.1

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

For a logical vector how would you find the xth position of true?(1)

A

which(y==TRUE)[xth].

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

Difference between dataframes, vectors and matrices in R?(1)

A

Vectors are 1 dimensional, Matrices and dataframes are 2 dimensional as have rows and columns
Dataframes different to matrix as matrices only numerical

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

What does rxc dataframe mean?(1)

A

Rows come before columns in dataframes in all cases.

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

How would you find the least used letter in a character vector?(1)

A

summary(as.factor(vector)) then take minimum and look to see which matches up.

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