Hi all! I am desperately trying to figure out the solution to this error, but nothing as of yet is working. As noted in an earlier post I am using GenABEL. In an attempt to read in the phenotype file, in the format .dat, R keeps giving me the error "more columns than column names" I have tried to read in the data without the headers; I have also tried to trim the data to remove any trailing tabs or spaces but it doesn't solve the problem. All missing values have been replaced with "NA", and all data seems to have matching corresponding header value - each column has a matching column name. What could be the possible underlying problem? I have tried to problem-solve but clearly I am at a loss. Thanks for your help! Code: mix <- load.gwaa.data (phe = "Z:/CCFPhenotypesTAB.dat", gen "pedmap-0.raw", force = T) -- View this message in context: http://n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p1568052.html Sent from the R help mailing list archive at Nabble.com.
I usually found this problem to be connected to spaces in the column names. Or, a wrong "sep" argument (for example "," instead of "\t" and the like) Let us know if it helped. Cheers, Tal ----------------Contact Details:------------------------------------------------------- Contact me: Tal.Galili@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) ---------------------------------------------------------------------------------------------- On Wed, Feb 24, 2010 at 11:14 PM, Euphoria <yeshapatel83@gmail.com> wrote:> > Hi all! I am desperately trying to figure out the solution to this error, > but > nothing as of yet is working. > > As noted in an earlier post I am using GenABEL. In an attempt to read in > the phenotype file, in the format .dat, R keeps giving me the error "more > columns than column names" > > I have tried to read in the data without the headers; I have also tried to > trim the data to remove any trailing tabs or spaces but it doesn't solve > the > problem. All missing values have been replaced with "NA", and all data > seems to have matching corresponding header value - each column has a > matching column name. > > What could be the possible underlying problem? I have tried to > problem-solve > but clearly I am at a loss. Thanks for your help! > > Code: > mix <- load.gwaa.data (phe = "Z:/CCFPhenotypesTAB.dat", gen > "pedmap-0.raw", force = T) > -- > View this message in context: > http://n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p1568052.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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. >[[alternative HTML version deleted]]
From the help page for the read.delim() function, under "See Also", suggests: 'count.fields' can be useful to determine problems with reading files which result in reports of incorrect record lengths. This is sometimes helpful. -Don At 1:14 PM -0800 2/24/10, Euphoria wrote:>Hi all! I am desperately trying to figure out the solution to this error, but >nothing as of yet is working. > >As noted in an earlier post I am using GenABEL. In an attempt to read in >the phenotype file, in the format .dat, R keeps giving me the error "more >columns than column names" > >I have tried to read in the data without the headers; I have also tried to >trim the data to remove any trailing tabs or spaces but it doesn't solve the >problem. All missing values have been replaced with "NA", and all data >seems to have matching corresponding header value - each column has a >matching column name. > >What could be the possible underlying problem? I have tried to problem-solve >but clearly I am at a loss. Thanks for your help! > >Code: > mix <- load.gwaa.data (phe = "Z:/CCFPhenotypesTAB.dat", gen >"pedmap-0.raw", force = T) >-- >View this message in context: >http://*n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p1568052.html >Sent from the R help mailing list archive at Nabble.com. > >______________________________________________ >R-help at 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.-- -------------------------------------- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062
I had a comment character "#" in my header names earlier today that threw this error. Euphoria wrote:> Hi all! I am desperately trying to figure out the solution to this error, but > nothing as of yet is working. > > As noted in an earlier post I am using GenABEL. In an attempt to read in > the phenotype file, in the format .dat, R keeps giving me the error "more > columns than column names" > > I have tried to read in the data without the headers; I have also tried to > trim the data to remove any trailing tabs or spaces but it doesn't solve the > problem. All missing values have been replaced with "NA", and all data > seems to have matching corresponding header value - each column has a > matching column name. > > What could be the possible underlying problem? I have tried to problem-solve > but clearly I am at a loss. Thanks for your help! > > Code: > mix <- load.gwaa.data (phe = "Z:/CCFPhenotypesTAB.dat", gen > "pedmap-0.raw", force = T)
On Feb 24, 2010, at 7:07 PM, Euphoria wrote:> > Thanks to all who posted. After trying all of the above-listed > options - the > error is still popping up, but here is some progress: > > 1) I can read in the file just fine when I use the read.table > statement and > specify it as a tab delimited file using the code: > > two <- read.table("Z:/CCFPhenotypesTAB.dat", head=TRUE, sep="\t") > > But, my issue is with GenABEL and the load.gwaa.data statement - I > need the > file to be read into load.gwaa.data - unless there is another way to > read in > the phenotype file in GenABEL. > > Code: > mix <- load.gwaa.data (phe = "Z:/CCFPhenotypesTAB.dat", gen > "pedmap-0.raw")The first line of that function body is this: dta <- read.table(phenofile, header = TRUE, as.is = TRUE) Notice that no provision was made for a supplied sep argument. Hack it so that it recognizes tab characters. Just changing hte extension designation will not allter the fact that iwas not designed to work with "tab" as a separator. Perhaps this as a replacement: dta <- read.table(phenofile, header = TRUE, as.is = TRUE, sep="\t") Or give the argument list a set of ellipses , ...) and the above line some ellipses to receive the argument. -- David.> > > 2) Also, it might help if I explained how I came about the .dat > file. It > was originally created in excel as a .xlsx file, which I converted > to a tab > delimited .txt file. I just changed the .txt extension to .dat for > it to be > read in R for the GenABEL package. > > -- > View this message in context: http://n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p1568313.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi there ... I see you had this problem last year, hope you solved it ... I had that same problem over and over again, it was due to my separator was , but . it means my keybord was set up on croatian instead of english, now works normaly ... cheers -- View this message in context: http://r.789695.n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p3841415.html Sent from the R help mailing list archive at Nabble.com.
Hi all, I had the same problem and I was trying to solve with several ways. However it was the most simple thing. While I was extracting the file from Excel to a csv file I was using "," instead of "." inside my numbers (for example "9,28" instead of "9.28") and each column was seperated with a ";" instead of ",". General rule: open your csv file first and see if everything is in position first. Then try mess with R! :-) Hope my silly mistake helps others to save some time. -- View this message in context: http://r.789695.n4.nabble.com/R-error-more-columns-than-column-names-tp1568052p4556655.html Sent from the R help mailing list archive at Nabble.com.