reading a txt file as i need
1
0
Entering edit mode
Angel ▴ 40
@angel-7981
Last seen 7.1 years ago
Berlin

hi,

i have such a file

head(mycounts[,1:4])
  AT2G26520 AT2G26530 AT2G26540 AT2G26510
1 AT2G26520   0.00000   0.51688   0.57686
2 AT2G26530   0.51688   0.00000   0.54974
3 AT2G26540   0.57686   0.54974   0.00000
4 AT2G26510   0.48842   0.52830   0.58760
5 AT2G23320   0.60273   0.64324   0.53196
6 AT2G39720   0.50206   0.54113   0.54894

but i need it like this

head(mycounts[,1:4])
                       AT2G26520 AT2G26530 AT2G26540 AT2G26510
1 AT2G26520   0.00000   0.51688   0.57686
2 AT2G26530   0.51688   0.00000   0.54974
3 AT2G26540   0.57686   0.54974   0.00000
4 AT2G26510   0.48842   0.52830   0.58760
5 AT2G23320   0.60273   0.64324   0.53196
6 AT2G39720   0.50206   0.54113   0.54894

but when i edit my file by adding tab to the first column i cant read my file anymore

and this is the error

Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
  line 1 did not have 2857 elements

how i can read my file as i need ????/

thank you

software error • 715 views
ADD COMMENT
1
Entering edit mode
@james-w-macdonald-5106
Last seen 1 day ago
United States

This is a basic R question, that doesn't really have anything to do with Bioconductor. In future, please direct this sort of question to R-help@r-project.org. Anyway, I doubt that your #2 is really what you want. Instead I would imagine you want the first column to be your row names. In which case you want to do

write.table(mycounts, "somefilename.txt", row.names = FALSE, colnames = TRUE, quote = FALSE)

mycounts <- read.table('somefilename.txt")

Which seems a bit silly - if you want those data in R, and you have them in R, why bother writing out and reading back in?

ADD COMMENT
0
Entering edit mode

thank you u all right.. my problem is basically

ADD REPLY

Login before adding your answer.

Traffic: 533 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6