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

前端 未结 6 691
说谎
说谎 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 19:47

    data.matrix(SFI)
    

    From ?data.matrix:

    Description:
    
     Return the matrix obtained by converting all the variables in a
     data frame to numeric mode and then binding them together as the
     columns of a matrix.  Factors and ordered factors are replaced by
     their internal codes.
    

提交回复
热议问题