Debjyoti
Debjyoti

Reputation: 177

Load data from a text file to R

I have data in text format whose structure is as follows:

ATCTTTGAT*TTAGGGGGAAAAATTCTACGC*TTACTGGACTATGCT
.........T.....,,,,,,,,,.......T,,,,,,.........
......A..*............,,,,,,,,.A........T......
    ....*..................,,,T...............
     ...*.....................*...........
           ...................*.....

I have been trying to import it into R using the read.table() command but when I do the output has an altered structure like this:

                                               V1
1 ATCTTTGAT*TTAGGGGGAAAAATTCTACGC*TTACTGGACTATGCT
2 .........T.....,,,,,,,,,.......T,,,,,,.........
3 ......A..*............,,,,,,,,.A........T......
4      ....*..................,,,T...............
5           ...*.....................*...........
6                       ...................*.....

For some reason, R is shifting the rows with lesser number of characters to the right. How can I load my data into R without altering the data structure present in the original text file?

Upvotes: 2

Views: 697

Answers (1)

Ferand Dalatieh
Ferand Dalatieh

Reputation: 353

Try this :)

read.table(file, sep = "\n")

result:

                                               V1
1 ATCTTTGAT*TTAGGGGGAAAAATTCTACGC*TTACTGGACTATGCT
2 .........T.....,,,,,,,,,.......T,,,,,,.........
3 ......A..*............,,,,,,,,.A........T......
4     ....*..................,,,T............... 
5      ...*.....................*...........     
6            ...................*.....           

Upvotes: 1

Related Questions