Convert data.frame columns from factors to characters

前端 未结 18 1458
时光取名叫无心
时光取名叫无心 2020-11-22 04:43

I have a data frame. Let\'s call him bob:

> head(bob)
                 phenotype                         exclusion
GSM399350 3- 4- 8- 25- 44+         


        
18条回答
  •  不要未来只要你来
    2020-11-22 05:18

    Another way is to convert it using apply

    bob2 <- apply(bob,2,as.character)
    

    And a better one (the previous is of class 'matrix')

    bob2 <- as.data.frame(as.matrix(bob),stringsAsFactors=F)
    

提交回复
热议问题