<p>I see spaces in the headings, which suggests this might be a tab-separated file, rather than a space-separated file. If that's the case, you should be using <code>sep=&quot;\t&quot;</code> in your <code>read.table</code> command, or alternatively using <code>read.delim</code>:</p>
<pre><code>gene_conversion &lt;-
  read.table(&quot;HOM_MouseHumanSequence.rpt.txt&quot;, sep=&quot;\t&quot;, header=T, fill=T)
</code></pre>
<p>or:</p>
<pre><code>gene_conversion &lt;- read.delim(&quot;HOM_MouseHumanSequence.rpt.txt&quot;)
</code></pre>

CC BY-SA 4.0
2021-08-04T13:45:49.627Z
On a related note, how can I subset based on just a column?
mmpp
CC BY-SA 4.0
2021-08-04T21:17:09.900Z
Can you please ask a separate question for that?
gringer
CC BY-SA 4.0
2021-08-04T13:07:51.783Z
2021-08-04T13:07:51.783Z
gringer
<p>Trying to read in this file but saved as a .txt file: <a href="http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt" rel="nofollow noreferrer">http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt</a></p>
<p><code>gene_conversion = read.table(&quot;HOM_MouseHumanSequence.rpt.txt&quot;,header=T, fill=T)</code></p>
<p>but the column names are splitting weirdly.</p>
<pre><code>&gt; head(gene_conversion)
        DB  Class        Key Common Organism       Name        NCBI Taxon    ID                      Symbol
1 38710983 mouse, laboratory  10090     Gdnf      14573  MGI:107430 Chr15   3.8                          cM
2 38710983  human       9606   GDNF     2668  HGNC:4232 OMIM:600837  Chr5 p13.2   Chr5:37812677-37840044(-)
3 38710984 mouse, laboratory  10090     Rrm1      20133   MGI:98180  Chr7 54.72                          cM
4 38710984  human       9606   RRM1     6240 HGNC:10451 OMIM:180410 Chr11 p15.4    Chr11:4094685-4138925(+)
5 38710985 mouse, laboratory  10090   Hoxd12      15432   MGI:96204  Chr2 44.13                          cM
6 38710985  human       9606 HOXD12     3238  HGNC:5135 OMIM:142988  Chr2 q31.1 Chr2:176099802-176100760(+)
                                                            EntrezGene
1                                             Chr15:7840327-7867056(+)
2 NM_199231,NM_001278098,NM_199234,NM_001190469,NM_001190468,NM_000514
3                                          Chr7:102090902-102118978(+)
4                     NM_001033,NM_001318065,NM_001330193,NM_001318064
5                                            Chr2:74505357-74508049(+)
6                                                            NM_021193
                                                                                  ID.1
1                                     NM_001301357,NM_010275,NM_001301333,NM_001301332
2 NP_001265027,NP_000505,NP_001177397,NP_001177398,XP_016864826,XP_011512332,NP_954701
3                                                                            NM_009103
4                                     NP_001024,NP_001317122,NP_001304994,NP_001304993
5                                                                            NM_008274
6                                                                            NP_067016
                                             Mouse    MGI ID.2 HGNC ID.3 OMIM Gene ID.4 Genetic Location Genomic
1 NP_001288286,NP_001288262,NP_034405,NP_001288261 P48540   NA   NA   NA   NA   NA   NA      NA       NA      NA
2                                           P39905          NA   NA   NA   NA   NA   NA      NA       NA      NA
3                                        NP_033129 P07742   NA   NA   NA   NA   NA   NA      NA       NA      NA
4                                           P23921          NA   NA   NA   NA   NA   NA      NA       NA      NA
5                                        NP_032300 P23812   NA   NA   NA   NA   NA   NA      NA       NA      NA
6                                           P35452          NA   NA   NA   NA   NA   NA      NA       NA      NA
  Coordinates X.mouse. X. human. X..1 Nucleotide RefSeq IDs Protein RefSeq.1 IDs.1 SWISS_PROT IDs.2
1          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
2          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
3          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
4          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
5          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
6          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
</code></pre>

<r>
loading in .txt files with different spacing in column names into R
# loading in .txt files with different spacing in column names into R

(Asked by: username_0 on 2021-08-03)

Trying to read in this file but saved as a .txt file: http://www.informatics.jax.org/downloads/reports/HOM_MouseHumanSequence.rpt
gene_conversion = read.table("HOM_MouseHumanSequence.rpt.txt",header=T, fill=T)
but the column names are splitting weirdly.
> head(gene_conversion)
        DB  Class        Key Common Organism       Name        NCBI Taxon    ID                      Symbol
1 38710983 mouse, laboratory  10090     Gdnf      14573  MGI:107430 Chr15   3.8                          cM
2 38710983  human       9606   GDNF     2668  HGNC:4232 OMIM:600837  Chr5 p13.2   Chr5:37812677-37840044(-)
3 38710984 mouse, laboratory  10090     Rrm1      20133   MGI:98180  Chr7 54.72                          cM
4 38710984  human       9606   RRM1     6240 HGNC:10451 OMIM:180410 Chr11 p15.4    Chr11:4094685-4138925(+)
5 38710985 mouse, laboratory  10090   Hoxd12      15432   MGI:96204  Chr2 44.13                          cM
6 38710985  human       9606 HOXD12     3238  HGNC:5135 OMIM:142988  Chr2 q31.1 Chr2:176099802-176100760(+)
                                                            EntrezGene
1                                             Chr15:7840327-7867056(+)
2 NM_199231,NM_001278098,NM_199234,NM_001190469,NM_001190468,NM_000514
3                                          Chr7:102090902-102118978(+)
4                     NM_001033,NM_001318065,NM_001330193,NM_001318064
5                                            Chr2:74505357-74508049(+)
6                                                            NM_021193
                                                                                  ID.1
1                                     NM_001301357,NM_010275,NM_001301333,NM_001301332
2 NP_001265027,NP_000505,NP_001177397,NP_001177398,XP_016864826,XP_011512332,NP_954701
3                                                                            NM_009103
4                                     NP_001024,NP_001317122,NP_001304994,NP_001304993
5                                                                            NM_008274
6                                                                            NP_067016
                                             Mouse    MGI ID.2 HGNC ID.3 OMIM Gene ID.4 Genetic Location Genomic
1 NP_001288286,NP_001288262,NP_034405,NP_001288261 P48540   NA   NA   NA   NA   NA   NA      NA       NA      NA
2                                           P39905          NA   NA   NA   NA   NA   NA      NA       NA      NA
3                                        NP_033129 P07742   NA   NA   NA   NA   NA   NA      NA       NA      NA
4                                           P23921          NA   NA   NA   NA   NA   NA      NA       NA      NA
5                                        NP_032300 P23812   NA   NA   NA   NA   NA   NA      NA       NA      NA
6                                           P35452          NA   NA   NA   NA   NA   NA      NA       NA      NA
  Coordinates X.mouse. X. human. X..1 Nucleotide RefSeq IDs Protein RefSeq.1 IDs.1 SWISS_PROT IDs.2
1          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
2          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
3          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
4          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
5          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA
6          NA       NA NA     NA   NA         NA     NA  NA      NA       NA    NA         NA    NA

**Tags:** r

---

## 1 answers

### Answer by username_1 on 2021-08-04. Score: 0 | Accepted answer

I see spaces in the headings, which suggests this might be a tab-separated file, rather than a space-separated file. If that's the case, you should be using sep="\t" in your read.table command, or alternatively using read.delim:
gene_conversion <-
  read.table("HOM_MouseHumanSequence.rpt.txt", sep="\t", header=T, fill=T)

or:
gene_conversion <- read.delim("HOM_MouseHumanSequence.rpt.txt")

> **Comments:**
> **username_0**: On a related note, how can I subset based on just a column?  
> **username_1**: Can you please ask a separate question for that?  

---

