changed as.data.frame to data.frame
added as.matrix to command for more flexibility