Complete the code to calculate the sum of each row in the matrix.
row_sums <- apply(matrix_data, [1], sum)The apply function with margin 1 applies the function to rows.
Complete the code to calculate the mean of each column in the matrix.
col_means <- apply(matrix_data, [1], mean)The apply function with margin 2 applies the function to columns.
Fix the error in the code to calculate the maximum value in each row.
max_values <- apply(matrix_data, [1], max)Margin 1 applies the function to rows, so use 1 to get max per row.
Fill both blanks to create a matrix of logical values where each element is TRUE if greater than 5.
result <- apply(matrix_data, [1], function(x) x [2] 5)
Margin 1 applies function to rows, and > checks if elements are greater than 5.
Fill all three blanks to create a named logical vector indicating which column sums are greater than 10.
result <- sapply(colnames(matrix_data), function([1]) sum(matrix_data[ , [2]]) [3] 10)
row instead of col causes indexing errors.Use col as the variable name, > to check sums greater than 10, and col again to index columns.