This is a test version of Biostars. For the public version, visit https://www.biostars.org.
as.integer function is converting row names in to number

I used to this

mydata3 <- data.frame(sapply(mydata2, as.integer))

but now i see that row names which is gene names, has been converted to number like 1-200). but i should point that same command i used sometimes ago then it was working well. So i thought there are some proenter code hereblem with my file then i used old file on which this command was working but i am seeing same problem like gene name is converted in to number here is full script-

countsTable<-read.table("JW.txt",header=TRUE,stringsAsFactors=TRUE,row.names=1)
mydata2 <- countsTable/1000
mydata3 <- data.frame(sapply(mydata2, as.integer))
str(mydata3)

please let me know.

r

1 answer

Explanation: your column is stored as factors

Solution1: as.integer(as.character(mycolumn))

Solution2: use stringAsFactors=F when reading the data

thnaks for comment

countsTable<-read.table("EF_new.txt",header=TRUE,stringsAsFactors=FALSE,row.names=1)

i used this but name is still vanishing and when i used

mydata3 <- data.frame(sapply(mydata2, as.integer(as.character(mydata2))))

so getting this error Error in match.fun(FUN) : 'as.integer(as.character(mydata2))' is not a function, character or symbol In addition: Warning message: In match.fun(FUN) : NAs introduced by coercion

hi thanks!! its working now. i changed it like this.

mydata2[] <- sapply(mydata2, as.integer)

Log in to answer this question.