how to convert a dataframe to a matrix and preserving the col and row names code example Example: data frame to matrix r data.matrix(frame, rownames.force = NA)