No matter how I´ve tried o find a solution for this simple question, I can´t. Sorry for bothering with such a matter. I have an excel-files with some empty cells=missing values. How do I tell R that these should be NA´s?> TRFLP1 <-(read.table(file="S://SEDIM//Kokeilu//TRFLP1.txt",col.names= c("Dye_Sample Peak", "Sample_File_Name", "Size", "Height", "Area_in_Point", "Area_in_BP", "Data_Point", "Begin_Point", "Begin_BP", "End_Point", "End_BP", "Width_in_Point", "Width_in_BP", "1" ), header=F , dec = ",", )Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1743 did not have 14 elementsI believe the error occurs becouse line 1743 has an empty cell. How do I read in the file without first checking for missing values and changing them to NAs myself? Thank you for you time, Monna Nygård _________________________________________________________________ [[alternative HTML version deleted]]
What exactly is on line 1743? Genuinely empty cells will probably read as NA anyway. Excel errors, prefixed # in excel, will be read as comment markers and cause the remainder of the line to be ignored. This often causes this kind of error. Steve E>>> Monna Nyg?rd <monnire at hotmail.com> 30/04/2008 11:51:16 >>>No matter how I?ve tried o find a solution for this simple question, I can?t. Sorry for bothering with such a matter. I have an excel-files with some empty cells=missing values. How do I tell R that these should be NA?s?> TRFLP1 <-(read.table(file="S://SEDIM//Kokeilu//TRFLP1.txt",col.names= c("Dye_Sample Peak", "Sample_File_Name", "Size", "Height", "Area_in_Point", "Area_in_BP", "Data_Point", "Begin_Point", "Begin_BP", "End_Point", "End_BP", "Width_in_Point", "Width_in_BP", "1" ), header=F , dec = ",", )Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1743 did not have 14 elementsI believe the error occurs becouse line 1743 has an empty cell. How do I read in the file without first checking for missing values and changing them to NAs myself? Thank you for you time, Monna Nyg?rd _________________________________________________________________ [[alternative HTML version deleted]] ******************************************************************* This email and any attachments are confidential. Any use...{{dropped:8}}
Monna Nyg?rd wrote:> No matter how I?ve tried o find a solution for this simple question, I can?t. Sorry for bothering with such a matter. > > I have an excel-files with some empty cells=missing values. How do I tell R that these should be NA?s? > > >> TRFLP1 <-(read.table(file="S://SEDIM//Kokeilu//TRFLP1.txt",col.names= c("Dye_Sample Peak", "Sample_File_Name", "Size", "Height", "Area_in_Point", "Area_in_BP", "Data_Point", "Begin_Point", "Begin_BP", "End_Point", "End_BP", "Width_in_Point", "Width_in_BP", "1" ), header=F , dec = ",", )Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1743 did not have 14 elements > > > I believe the error occurs becouse line 1743 has an empty cell. How do I read in the file without first checking for missing values and changing them to NAs myself? >Hi Monna, read.table has an argument "na.strings" that allows you to specify what will be read as a missing value. Setting this to na.strings="" should get you there. Jim
How are the 'empty' cell identified? It appears that you are using the default of read.table which says blanks are the delimiters. How are two or more empty cells identified? Can you output a CSV file so that you have commas as separators so you can identify the empty fields? On Wed, Apr 30, 2008 at 6:51 AM, Monna Nyg?rd <monnire at hotmail.com> wrote:> > No matter how I?ve tried o find a solution for this simple question, I can?t. Sorry for bothering with such a matter. > > I have an excel-files with some empty cells=missing values. How do I tell R that these should be NA?s? > > > TRFLP1 <-(read.table(file="S://SEDIM//Kokeilu//TRFLP1.txt",col.names= c("Dye_Sample Peak", "Sample_File_Name", "Size", "Height", "Area_in_Point", "Area_in_BP", "Data_Point", "Begin_Point", "Begin_BP", "End_Point", "End_BP", "Width_in_Point", "Width_in_BP", "1" ), header=F , dec = ",", )Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 1743 did not have 14 elements > > I believe the error occurs becouse line 1743 has an empty cell. How do I read in the file without first checking for missing values and changing them to NAs myself? > > Thank you for you time, > > Monna Nyg?rd > _________________________________________________________________ > > > [[alternative HTML version deleted]] > > > ______________________________________________ > 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. > >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?