error in reading text files in qiime2R package of R studio

Hi everyone.
I am working with qiime2R package in Rstudio for making some plots. I successfully installed the package. But when I tried to read my metadata for further analysis, it is giving me an error "more columns than column names". The text file is attached with the post.


library (qiime2R)
metadata_genevstemp <-read_q2metadata("sample_metadata_genevstemp.txt")


metadata_genevstemp <-read_q2metadata("sample_metadata_genevstemp.txt")
Error in read.table(file, header = F, col.names = coltitles, skip = 2,  : 
  more columns than column names

Can anyone please help me to get rid of this problem. Thank you very much.

sample_metadata_genevstemp.txt (3.9 KB)

Hi @ssanjee,
The issue seems to be that there are tabs following the information on each line in your file. This is easiest to diagnose using a text editor that has support for showing whitespace characters. For example, I opened this in TextMate and I can see that there are tabs following each line (represented by the triangles).

TextMate is a macOS only tool. A good (and also free) Windows option is Notepad++.

The solution will be to open that file in a text editor, and delete all whitespace between the last text and the newline character (represented by the sideways L in my screenshot).

Hope this helps, good luck!

1 Like

Thank you very much. I really appreciate it.
It worked.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.