Hi all, I am trying to red data where single and double quotes are embedded in some of the fields and prevented to read the data. As an example please see below. vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5 ",header=TRUE) Error in read.table(text = "name prof \n A '4.5 \n B 3.2 \n C 5.5 ", : incomplete final line found by readTableHeader on 'text' Is there a way how to read this data and gt the following output name prof 1 A 4.5 2 B 3.2 3 C 5.5 Thank you inadvertence
Hi you can save your data file in txt or csv file. Then you can use function " vld <-read.table("C:/Users/........ .txt",header=T)". Regards Mayooran -----Original Message----- From: R-help <r-help-bounces at r-project.org> On Behalf Of Val Sent: Friday, 9 August 2019 12:11 PM To: r-help at R-project.org (r-help at r-project.org) <r-help at r-project.org> Subject: [R] read Hi all, I am trying to red data where single and double quotes are embedded in some of the fields and prevented to read the data. As an example please see below. vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5 ",header=TRUE) Error in read.table(text = "name prof \n A '4.5 \n B 3.2 \n C 5.5 ", : incomplete final line found by readTableHeader on 'text' Is there a way how to read this data and gt the following output name prof 1 A 4.5 2 B 3.2 3 C 5.5 Thank you inadvertence ______________________________________________ R-help at 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.
read.table() does not have a "text" argument, so maybe you need to go back and go through a tutorial or two to learn R basics (e.g. about function calls and function arguments ?) See ?read.table (of course) Cheers, Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Thu, Aug 8, 2019 at 5:11 PM Val <valkremk at gmail.com> wrote:> Hi all, > > I am trying to red data where single and double quotes are embedded > in some of the fields and prevented to read the data. As an example > please see below. > > vld<-read.table(text="name prof > A '4.5 > B "3.2 > C 5.5 ",header=TRUE) > > Error in read.table(text = "name prof \n A '4.5 \n B > 3.2 \n C 5.5 ", : > incomplete final line found by readTableHeader on 'text' > > Is there a way how to read this data and gt the following output > name prof > 1 A 4.5 > 2 B 3.2 > 3 C 5.5 > > Thank you inadvertence > > ______________________________________________ > R-help at 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. >[[alternative HTML version deleted]]
data <- read.table(header=TRUE, text=' name prof A 4.5 B 3.2 C 5.5 ')> On 9 Aug 2019, at 8:11 AM, Val <valkremk at gmail.com> wrote: > > Hi all, > > I am trying to red data where single and double quotes are embedded > in some of the fields and prevented to read the data. As an example > please see below. > > vld<-read.table(text="name prof > A '4.5 > B "3.2 > C 5.5 ",header=TRUE) > > Error in read.table(text = "name prof \n A '4.5 \n B > 3.2 \n C 5.5 ", : > incomplete final line found by readTableHeader on 'text' > > Is there a way how to read this data and gt the following output > name prof > 1 A 4.5 > 2 B 3.2 > 3 C 5.5 > > Thank you inadvertence > > ______________________________________________ > R-help at 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.
Thank you all, I can read the text file but the problem was there is a single quote embedded in the first row of second column. This quote causes the problem vld<-read.table(text="name prof A '4.5 B "3.2 C 5.5 ",header=TRUE) On Thu, Aug 8, 2019 at 7:24 PM Anaanthan Pillai <anaanthanpillai at gmail.com> wrote:> > data <- read.table(header=TRUE, text=' > name prof > A 4.5 > B 3.2 > C 5.5 > ') > > On 9 Aug 2019, at 8:11 AM, Val <valkremk at gmail.com> wrote: > > > > Hi all, > > > > I am trying to red data where single and double quotes are embedded > > in some of the fields and prevented to read the data. As an example > > please see below. > > > > vld<-read.table(text="name prof > > A '4.5 > > B "3.2 > > C 5.5 ",header=TRUE) > > > > Error in read.table(text = "name prof \n A '4.5 \n B > > 3.2 \n C 5.5 ", : > > incomplete final line found by readTableHeader on 'text' > > > > Is there a way how to read this data and gt the following output > > name prof > > 1 A 4.5 > > 2 B 3.2 > > 3 C 5.5 > > > > Thank you inadvertence > > > > ______________________________________________ > > R-help at 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. >
Val 1 Bert 0 On August 8, 2019 5:22:13 PM PDT, Bert Gunter <bgunter.4567 at gmail.com> wrote:>read.table() does not have a "text" argument, so maybe you need to go >back >and go through a tutorial or two to learn R basics (e.g. about function >calls and function arguments ?) >See ?read.table (of course) > >Cheers, > >Bert Gunter > >"The trouble with having an open mind is that people keep coming along >and >sticking things into it." >-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) > > >On Thu, Aug 8, 2019 at 5:11 PM Val <valkremk at gmail.com> wrote: > >> Hi all, >> >> I am trying to red data where single and double quotes are embedded >> in some of the fields and prevented to read the data. As an example >> please see below. >> >> vld<-read.table(text="name prof >> A '4.5 >> B "3.2 >> C 5.5 ",header=TRUE) >> >> Error in read.table(text = "name prof \n A '4.5 \n B >> 3.2 \n C 5.5 ", : >> incomplete final line found by readTableHeader on 'text' >> >> Is there a way how to read this data and gt the following output >> name prof >> 1 A 4.5 >> 2 B 3.2 >> 3 C 5.5 >> >> Thank you inadvertence >> >> ______________________________________________ >> R-help at 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. >> > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at 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.-- Sent from my phone. Please excuse my brevity.