0

Possible Duplicate:
Convert factor to integer in a data frame

I have the following code

anna.table<-data.frame (anna1,anna2)
write.table<-(anna.table, file="anna.file.txt",sep='\t', quote=FALSE) 

my table in the end contains numbers such as the following

chr  start end    score
2    123   322   1,21E+07
.     .     .       .
.     .     .       .
.     .     .       .
.     .     .       .
.     .     .       .

and so on......

after that I am trying to to get only the values which fit some criteria such as score less than a specific value

so I am doing the following

anna2<-"data/anna/anna.file.txt"
anna.total<-read.table(anna2,header=TRUE)
significant.anna<-subset(anna.total,score <=0.001)

Error: In Ops.factor(score, 0.001) <= not meaningful for factors

so I guess the problem is that my table has factors and not integers

I guess that my anna.total$score is a factor and i must make it an integer

If I read correctly the as.numeric might solve my problem

I am reading about the as.numeric function but I cannot understand how I can use it

Hence could you please give me some advices?

Community
  • 1
  • 1
Anna
  • 147
  • 2
  • 4
  • 12
  • What was wrong with the advice/Answer I gave to this question? http://stackoverflow.com/q/9480408/429846 ??? I'm flagging this for closure as it is essentially the same as the previous question I answered. – Gavin Simpson Feb 28 '12 at 13:13
  • Please edit the original question instead of posting a duplicate. – Bill the Lizard Feb 28 '12 at 13:17
  • my apologies....for some reason i cannot enter my previous question...Gavin Simpson i am sorry i cannot see neither my question nor your comment...I am very sorry...That's why i thought that i made a mistake and my question was not published – Anna Feb 28 '12 at 13:20

0 Answers0