Convert factor to integer in a data frame

前端 未结 2 1131
梦毁少年i
梦毁少年i 2020-12-01 19:57

I have the following code

anna.table<-data.frame (anna1,anna2)
write.table<-(anna.table, file=\"anna.file.txt\",sep=\'\\t\', quote=FALSE) 
2条回答
  •  囚心锁ツ
    2020-12-01 21:03

    I know this is an older question, but I just had the same problem and may be it helps:

    In this case, your score column seems like it should not have become a factor column. That usually happens after read.table when it is a text column. Depending on which country you are from, may be you separate floats with a "," and not with a ".". Then R thinks that is a character column and makes it a factor. AND in that case Gavins answer won't work, because R won't make "123,456" to 123.456 . You can easily fix that in a text editor with replace "," with "." though.

提交回复
热议问题