Right way to convert data.frame to a numeric matrix, when df also contains strings?

前端 未结 6 677
说谎
说谎 2020-12-22 19:34

I have a data frame taken from a .csv-file which contains numeric and character values. I want to convert this data frame into a matrix. All containing information is number

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-22 20:00

    Here is an alternative way if the data frame just contains numbers.

    apply(as.matrix.noquote(SFI),2,as.numeric)

    but the most reliable way of converting a data frame to a matrix is using data.matrix() function.

提交回复
热议问题