## Convert DataFrame to Matrix in R

To convert DataFrame to Matrix in R using the ‘as.matrix()‘ function: mat <- as.matrix(df) For example: # Create a DataFrame df <- data.frame( col_a = c(1, 2, 3), col_b = c(4, 5, 6), col_c = c(7, 8, 9) ) # Convert the DataFrame to a Matrix in R mat <- as.matrix(df) # Print the Matrix … Read more