R convert dataframe to matrix, specifying which are rows and columns code example Example: data frame to matrix r data.matrix(frame, rownames.force = NA)