Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a problem with read.table when using # as seperator?

I’m trying to read in a text file (via read.table()) which looks like this:

1#2#3
4#5#6
7#8#9

The "#" should be used as the field’s seperator.

My code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

test_data <- read.table("a_test_file.csv", sep= "#")

I’m only able to read in the first column (the values 1,4,7). Is there something I don’t see or any ideas concerning a workaround?

Edit: I just realize that # is used to insert coments which are not treated as code text. Could it be that this sign is kind of ‘locked’ for any other purposes than creating coments?

>Solution :

Set comment.char to something else, e.g.:

test_data <- read.table("a_test_file.csv", sep = "#", comment.char = "")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading