Suppose I have a tab delimited file as the following:
chr1 234 3.24
chr1 345 2.11
chr2 123 8.99
...
chrX 879 0.24
...
Then in R, I use "read.table" to read the file into a variable "d", the head of the "d" looks normal chr1 234 3.24 chr1 345 2.11 chr2 123 8.99 ...
But when I use "cbind(d[,1], d[,2], d[,3])" and assign it to another variable, say, "b", then "b" looks like
1 234 3.24
1 345 2.11
2 123 8.99
...
23 879 0.24 # "chrX" is automatically converted to "23"
...
That is odd. It looks like "cbind" treats characters as factors and used the factor numbers (e.g. 1, 2, ..., 23) to replace the strings (chr1, chr2, ..., chrX).
How to avoid this?
I know this might not be the best forum to ask the question, but since you guys are so great and I believe some of you have the answers!
try to use this site to answer your question
http://rseek.org/
You don't want to do the necessary "re"search on web?
I certainly did but found no answers. Weird.
So the problem is while reading the table, strings are read As Factors? Is that True?
The problem is "cbind" automatically convert strings to factor numbers, e.g. "chr1" => "1", "chrM" => "23", "chrX" => "24", "chrM" to "25".
No the problem is in read.table
;-)