Treat "#" as a regular character when reading data

I'm pretty sure this was asked before, but due to a certain social media app that I got drowned in unrelated search results.

So the dataset I'm importing contains the actual "#" as in Apartment # 404, and I would like to save the character if possible, but R thinks it's the end of the line or something. First it will bomb at the first occurrence, then I set fill = TRUE and now it just ignores the rest of the line after that.

How do I instruct R to treat # as regular characters?

+3


source to share


1 answer


If you are not using the "#" character as a comment character in your data, you can use

read.table(..., comment.char="")

      



This should treat "#" like any other character.

+9


source







All Articles