Re: [R] rows missing after dataset loaded to R
Many thanks to all of you :handshake: Gabor Grothendieck wrote: > > Another situation would be if you have comment characters in strings that > are intended to be content. > > On Thu, Jul 23, 2009 at 5:35 PM, Greg Snow wrote: >> Some programs quote everything to be "safe", others only quote when >> needed. The only case that I know of that read.table and friends require >> quotes for is when a separator is inside of a string, for example if you >> are using spaces as the separator and have some names with spaces in them >> (e.g. "North Dakota"), without the quotes that would be seen as 2 fields, >> with the quotes it is a single field. If the coma (,) is the separator >> and you have names (e.g. "Snow, Greg") then you would need the quotes. >> If you don't have any cases of the separators other than where they are >> separating fields, then the quotes are probably not needed. >> >> Hope this helps, >> >> -- >> Gregory (Greg) L. Snow Ph.D. >> Statistical Data Center >> Intermountain Healthcare >> greg.s...@imail.org >> 801.408.8111 >> >> >>> -Original Message- >>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >>> project.org] On Behalf Of Rnewbie >>> Sent: Thursday, July 23, 2009 11:02 AM >>> To: r-help@r-project.org >>> Subject: Re: [R] rows missing after dataset loaded to R >>> >>> >>> Thank you very much for the reply. I checked the rows and it was the >>> unbalanced " quote marks in some of the rows that caused the problem. >>> Once I >>> disabled quoting altogether, the problem is solved. >>> >>> I have one more basic question. I disabled quoting when loading the >>> file to >>> R, and all the columns consisting of characters with or without >>> quotation >>> marks displayed normally. What does quoting actually do in R? >>> >>> -- >>> View this message in context: http://www.nabble.com/rows-missing-after- >>> dataset-loaded-to-R-tp24625882p24630154.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. >> >> __ >> 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. >> > > __ > 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. > > -- View this message in context: http://www.nabble.com/rows-missing-after-dataset-loaded-to-R-tp24625882p24642027.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.
Re: [R] rows missing after dataset loaded to R
Another situation would be if you have comment characters in strings that are intended to be content. On Thu, Jul 23, 2009 at 5:35 PM, Greg Snow wrote: > Some programs quote everything to be "safe", others only quote when needed. > The only case that I know of that read.table and friends require quotes for > is when a separator is inside of a string, for example if you are using > spaces as the separator and have some names with spaces in them (e.g. "North > Dakota"), without the quotes that would be seen as 2 fields, with the quotes > it is a single field. If the coma (,) is the separator and you have names > (e.g. "Snow, Greg") then you would need the quotes. If you don't have any > cases of the separators other than where they are separating fields, then the > quotes are probably not needed. > > Hope this helps, > > -- > Gregory (Greg) L. Snow Ph.D. > Statistical Data Center > Intermountain Healthcare > greg.s...@imail.org > 801.408.8111 > > >> -Original Message- >> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- >> project.org] On Behalf Of Rnewbie >> Sent: Thursday, July 23, 2009 11:02 AM >> To: r-help@r-project.org >> Subject: Re: [R] rows missing after dataset loaded to R >> >> >> Thank you very much for the reply. I checked the rows and it was the >> unbalanced " quote marks in some of the rows that caused the problem. >> Once I >> disabled quoting altogether, the problem is solved. >> >> I have one more basic question. I disabled quoting when loading the >> file to >> R, and all the columns consisting of characters with or without >> quotation >> marks displayed normally. What does quoting actually do in R? >> >> -- >> View this message in context: http://www.nabble.com/rows-missing-after- >> dataset-loaded-to-R-tp24625882p24630154.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. > > __ > 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. > __ 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.
Re: [R] rows missing after dataset loaded to R
Some programs quote everything to be "safe", others only quote when needed. The only case that I know of that read.table and friends require quotes for is when a separator is inside of a string, for example if you are using spaces as the separator and have some names with spaces in them (e.g. "North Dakota"), without the quotes that would be seen as 2 fields, with the quotes it is a single field. If the coma (,) is the separator and you have names (e.g. "Snow, Greg") then you would need the quotes. If you don't have any cases of the separators other than where they are separating fields, then the quotes are probably not needed. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Rnewbie > Sent: Thursday, July 23, 2009 11:02 AM > To: r-help@r-project.org > Subject: Re: [R] rows missing after dataset loaded to R > > > Thank you very much for the reply. I checked the rows and it was the > unbalanced " quote marks in some of the rows that caused the problem. > Once I > disabled quoting altogether, the problem is solved. > > I have one more basic question. I disabled quoting when loading the > file to > R, and all the columns consisting of characters with or without > quotation > marks displayed normally. What does quoting actually do in R? > > -- > View this message in context: http://www.nabble.com/rows-missing-after- > dataset-loaded-to-R-tp24625882p24630154.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. __ 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.
Re: [R] rows missing after dataset loaded to R
Thank you very much for the reply. I checked the rows and it was the unbalanced " quote marks in some of the rows that caused the problem. Once I disabled quoting altogether, the problem is solved. I have one more basic question. I disabled quoting when loading the file to R, and all the columns consisting of characters with or without quotation marks displayed normally. What does quoting actually do in R? -- View this message in context: http://www.nabble.com/rows-missing-after-dataset-loaded-to-R-tp24625882p24630154.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.
Re: [R] rows missing after dataset loaded to R
try using the options: quote='', comment.char='' You might have a comment character ("#") or unbalanced quote marks. Look closely at the rows that your missing, especially several rows prior to them. On Thu, Jul 23, 2009 at 9:35 AM, Rnewbie wrote: > > Dear all, > > When I loaded a dataset (a txt file), which is structured in a tabular > format, to R by using read.delim, I found some rows were missing. The column > number was correct. These missing rows are no apparently different from the > other rows, and for some unknown reasons these missing rows scattered among > the last 50 rows of the dataset. Then after I tried to open this txt file in > Excel and simply saved it as txt file to overwrite the original txt file > without making any further changes, no rows disappeared when I loaded the > new txt file into R again. > > I hope someone could give me ideas what could have gone wrong with my > dataset file. Thanks in advance. > -- > View this message in context: > http://www.nabble.com/rows-missing-after-dataset-loaded-to-R-tp24625882p24625882.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. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ 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.
[R] rows missing after dataset loaded to R
Dear all, When I loaded a dataset (a txt file), which is structured in a tabular format, to R by using read.delim, I found some rows were missing. The column number was correct. These missing rows are no apparently different from the other rows, and for some unknown reasons these missing rows scattered among the last 50 rows of the dataset. Then after I tried to open this txt file in Excel and simply saved it as txt file to overwrite the original txt file without making any further changes, no rows disappeared when I loaded the new txt file into R again. I hope someone could give me ideas what could have gone wrong with my dataset file. Thanks in advance. -- View this message in context: http://www.nabble.com/rows-missing-after-dataset-loaded-to-R-tp24625882p24625882.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.