Question: as.integer function is converting row names in to number
gravatar for singhsk2622
2.8 years ago by
singhsk262210 wrote:

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-

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

please let me know.

R • 553 views
ADD COMMENTlink modified 2.8 years ago by Devon Ryan97k • written 2.8 years ago by singhsk262210
gravatar for Giovanni M Dall'Olio
2.8 years ago by
London, UK
Giovanni M Dall'Olio27k wrote:

Explanation: your column is stored as factors

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

Solution2: use stringAsFactors=F when reading the data

ADD COMMENTlink modified 2.8 years ago • written 2.8 years ago by Giovanni M Dall'Olio27k

thnaks for comment


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 : 'as.integer(as.character(mydata2))' is not a function, character or symbol In addition: Warning message: In : NAs introduced by coercion

ADD REPLYlink written 2.8 years ago by singhsk262210

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

mydata2[] <- sapply(mydata2, as.integer)
ADD REPLYlink written 2.8 years ago by singhsk262210
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2428 users visited in the last hour