Working with matrices Flashcards

1
Q

Assign name attributes to rows of a matrix

A

rownames(matrix)

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

Assign name attributes to columns of a matrix

A

colnames(matrix)

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

Finding matrix dimensions

A

dim(math_chemistry)

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

Combining vectors or matrices by row

A

rbind(matrix_1, matrix_2)
rbind(vector_1, vector_2)
rbind(vector_1, matrix_1)

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

Combining vectors or matrices by column

A

cbind(matrix_1, matrix_2)
cbind(vector_1, vector_2)
cbind(vector_1, matrix_1)

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

Extract a single element

A

matrix[2, 5]

matrix[“row”, “column”]

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

Extract multiple elements

A

matrix[c(1, 2), c(1, 3)]

matrix[c(“Harvard”, “Stanford”), c(“world_rank, “influence”)]

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

Extract a single row

A

matrix[1, ]

matrix[“Harvard”, ]

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

Extract a single column

A

matrix[ , 2]

matrix[ , “quality_of_education”]

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

Extract multiple rows or columns

A

matrix[c(2, 4, 5), ]

matrix[ , c(“quality”, “influence”, impact”)]

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

Sum of values in a matrix

A

sum(matrix[ , “column_name”])

sum(matrix[“row_name”, ])

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