Cannot read file with "#" and space using read.table or read.csv in R
From the documentation (?read.csv
):
comment.char character: a character vector of length one containing a single character or an empty string. Use "" to turn off the interpretation of comments altogether.
The default is comment.char = "#"
which is causing you trouble. Following the documentation, you should use comment.char = ""
.
Spaces in the header is another issue which, as mrdwab kindly pointed out, can be addressed by setting check.names = FALSE
.
chromosomes <- read.csv(chromFile, sep = "\t", skip = 0, header = TRUE, comment.char = "", check.names = FALSE)