making a factor numeric
Hi,
I have a file contains gene name and length, like below
> genes <- as.data.frame(read.csv("geneID and length.txt",header = FALSE, sep=","),stringsAsFactors=FALSE)
> head(genes[1:2])
V1 V2
1 genesID geneslength
2 R0010W 1272
3 R0020C 1122
4 R0030W 546
5 R0040C 891
6 YAL069W 315
> genesID <- genes[,1]
> geneslength <- genes[,2]
I used ncol=(as.integer(max(geneslength))) but error:
Error in Summary.factor(c(1368L, 115L, 53L, 1135L, 1317L, 776L, 593L, :
'max' not meaningful for factors
How I can make geneslength numeric please?
Thank you
• 83 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Kind reminder, this is not the right place for pure r questions. So you are having a question about "numeric"? Did you try
See https://stackoverflow.com/questions/3418128/how-to-convert-a-factor-to-an-integer-numeric-without-a-loss-of-information