Re: [R] different between read.table and read.delim
In the future you can examine the consequence kid various choices for parameters with something along the lines of table( count.fields( file= .. , ... )) Sent from my iPhone > On Dec 22, 2016, at 9:13 PM, Jinsong Zhao wrote: > >> On 2016/12/23 11:31, Sarah Goslee wrote: >> Look at the default arguments to each, especially the quote argument. >> >> Sarah >> > > Thank you very much! > > The quote and fill argument are not same for the two function. only change > quote or fill can not make read.table() work. > > Best, > Jinsong > >>> On Thu, Dec 22, 2016 at 10:24 PM, Jinsong Zhao wrote: >>> Hi there, >>> >>> I have a data set file, called "ecotox.rep", which is a delimited file >>> separated with "|". >>> >>> When I tried to read the file with the following command, >>> df <- read.table("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) >>> >>> I got the error messages: >>> >>> Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, >>> : >>> line 113 did not have 87 elements >>> >>> However, when I read the file with the following command, >>> df <- read.delim("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) >>> >>> I got a correct output. >>> >>> If I understand correctly, read.delim() is just wrapped from read.table(), >>> why read.delim() works, but read.table() doesn't. >>> >>> Thanks in advance. >>> >>> Best, >>> Jinsong > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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] different between read.table and read.delim
On 2016/12/23 11:31, Sarah Goslee wrote: Look at the default arguments to each, especially the quote argument. Sarah Thank you very much! The quote and fill argument are not same for the two function. only change quote or fill can not make read.table() work. Best, Jinsong On Thu, Dec 22, 2016 at 10:24 PM, Jinsong Zhao wrote: Hi there, I have a data set file, called "ecotox.rep", which is a delimited file separated with "|". When I tried to read the file with the following command, df <- read.table("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) I got the error messages: Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 113 did not have 87 elements However, when I read the file with the following command, df <- read.delim("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) I got a correct output. If I understand correctly, read.delim() is just wrapped from read.table(), why read.delim() works, but read.table() doesn't. Thanks in advance. Best, Jinsong __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] different between read.table and read.delim
Look at the default arguments to each, especially the quote argument. Sarah On Thu, Dec 22, 2016 at 10:24 PM, Jinsong Zhao wrote: > Hi there, > > I have a data set file, called "ecotox.rep", which is a delimited file > separated with "|". > > When I tried to read the file with the following command, > >> df <- read.table("ecotox.rep", sep = "|", header = TRUE, >> stringsAsFactors=FALSE) > > I got the error messages: > > Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, > : > line 113 did not have 87 elements > > However, when I read the file with the following command, > >> df <- read.delim("ecotox.rep", sep = "|", header = TRUE, >> stringsAsFactors=FALSE) > > I got a correct output. > > If I understand correctly, read.delim() is just wrapped from read.table(), > why read.delim() works, but read.table() doesn't. > > Thanks in advance. > > Best, > Jinsong > __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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] different between read.table and read.delim
Hi there, I have a data set file, called "ecotox.rep", which is a delimited file separated with "|". When I tried to read the file with the following command, > df <- read.table("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) I got the error messages: Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 113 did not have 87 elements However, when I read the file with the following command, > df <- read.delim("ecotox.rep", sep = "|", header = TRUE, stringsAsFactors=FALSE) I got a correct output. If I understand correctly, read.delim() is just wrapped from read.table(), why read.delim() works, but read.table() doesn't. Thanks in advance. Best, Jinsong __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.