Convert data.frame columns from factors to characters

前端 未结 18 1564
时光取名叫无心
时光取名叫无心 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:09

    Update: Here's an example of something that doesn't work. I thought it would, but I think that the stringsAsFactors option only works on character strings - it leaves the factors alone.

    Try this:

    bob2 <- data.frame(bob, stringsAsFactors = FALSE)
    

    Generally speaking, whenever you're having problems with factors that should be characters, there's a stringsAsFactors setting somewhere to help you (including a global setting).

提交回复
热议问题