Hi! You can try import the file with header = F, and after inform that the first row is a header.
On this post is some idea: http://stackoverflow.com/questions/2293131/reading-first-row-as-header-is-easy-what-gives-with-two-rows-being-the-header On Wed, Aug 17, 2011 at 10:03 AM, Jack Luo <jluo.rh...@gmail.com> wrote: > 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]] > > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Atenciosamente, Raphael Saldanha saldanha.plan...@gmail.com [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.