Hi,

I have a silly question regarding the usage of two commands: read.table and
gregexpr：
For read.table, if I read a matrix and set header = T, I found that all the
dash ("-") becomes dots (".")


A = read.table("Matrix.txt", sep = "\t", header = F)
A[1,1]
# "A-B-C-D".

A = read.table("Matrix.txt", sep = "\t", header = T)
colnames(A)[1]
# "A.B.C.D"

Is there a way to use the header = T argument, but still keep the original
format "A-B-C-D"?

For gregexpr,
gregexpr("-","A-B-C-D")[[1]]
#[1] 2 4 6
#attr(,"match.length")
#[1] 1 1 1


gregexpr(".","A.B.C.D")[[1]]
[1] 1 2 3 4 5 6 7
attr(,"match.length")
[1] 1 1 1 1 1 1 1

Looks like dots means all the characters. Is there a way that I can extract
the position of the dots specifically?

Thanks,

-Jack

	[[alternative HTML version deleted]]

