Why do you first convert to a matrix and then to a data frame instead of converting to a data frame immediately?