Hi Arun, I finally got the output file (attached here). It has multiple rows. could you help me read it in R?
On Fri, Mar 22, 2013 at 3:35 PM, arun kirshna [via R] < ml-node+s789695n4662243...@n4.nabble.com> wrote: > Hi, > Try this: > con<-file("Rout2122.text") > Lines1<- readLines(con) > close(con) > > indx<-rep(c(TRUE,FALSE),each=2) #changed here > Lines2<-Lines1[!grepl("[A-Za-z]",Lines1)] > res<-read.table(text=paste(gsub("^\\s+","",Lines2[indx]),gsub("^\\s+","",Lines2[!indx])),sep="",header=FALSE)#some > changes > nm1<-unlist(strsplit(gsub("^ > +","",paste(Lines1[grepl("[A-Za-z]",Lines1)][1:2],collapse=" "))," ")) > colnames(res)<- nm1[nm1!=""] > res > # m1 n1 m n cterm1_P0L cterm1_P0H c11 c12 c1 c2 alpha beta > T_error N > #1 4 4 10 8 0.8145062 0.6634204 0.03 0.05 0.15 0.2 0.1 0.4 > 0.6918138 18 > #2 5 4 9 8 0.7737809 0.6302494 0.03 0.05 0.15 0.2 0.1 0.4 > 0.6643599 17 > # EN BH BL AH AL > #1 10.45928 0.1690183 0.3952494 0.07470420 0.05284197 > #2 11.38388 0.1694641 0.3624458 0.07208597 0.06036395 > A.K. > > > > > > > ________________________________ > From: Zjoanna <[hidden > email]<http://user/SendEmail.jtp?type=node&node=4662243&i=0>> > > To: [hidden email] <http://user/SendEmail.jtp?type=node&node=4662243&i=1> > Sent: Friday, March 22, 2013 3:54 PM > Subject: Re: [R] Reading dataset in R > > Hi, > > I also need to read this format of file in R, it is a Wordpad file. > > > On Thu, Mar 21, 2013 at 5:07 PM, arun <[hidden > email]<http://user/SendEmail.jtp?type=node&node=4662243&i=2>> > wrote: > > > > > > > Hi, > > con<-file("Rout1112.text") > > Lines1<- readLines(con) > > close(con) > > indx<-rep(rep(c(TRUE,FALSE),each=2),2) > > Lines2<-Lines1[!grepl("[A-Za-z]",Lines1)] > > > > > > > res<-read.table(text=paste(gsub("^\\d+\\s+","",Lines2[indx]),gsub("^\\d+\\s+","",Lines2[!indx])),sep="",header=FALSE) > > > nm1<-unlist(strsplit(gsub("^ > > +","",paste(Lines1[grepl("[A-Za-z]",Lines1)][1:2],collapse=" "))," ")) > > colnames(res)<- nm1[nm1!=""] > > res > > #m1 n1 m n cterm1_P0L cterm1_P0H c11 c12 c1 c2 alpha beta > > T_error N > > #1 4 5 11 9 0.8145062 0.6302494 0.03 0.03 0.15 0.15 0.1 0.4 > > 0.6339515 20 > > #2 7 4 11 8 0.6983373 0.0000000 0.03 0.03 0.15 0.15 0.1 0.4 > > 0.4899431 19 > > #3 4 5 10 9 0.8145062 0.6302494 0.03 0.03 0.15 0.20 0.1 0.4 > > 0.6831988 19 > > #4 5 4 9 8 0.7737809 0.0000000 0.03 0.03 0.15 0.20 0.1 0.4 > > 0.6458095 17 > > # EN BH BL AH AL > > #1 11.77746 0.12159579 0.3846999 0.09567271 0.03198315 > > #2 16.20665 0.09819012 0.2550532 0.09581478 0.04088503 > > #3 11.59196 0.15166360 0.3943098 0.08405337 0.05317206 > > #4 13.90488 0.14031630 0.3624458 0.08268336 0.06036395 > > A.K. > > > > ________________________________ > > From: Joanna Zhang <[hidden > > email]<http://user/SendEmail.jtp?type=node&node=4662243&i=3>> > > > To: arun <[hidden > > email]<http://user/SendEmail.jtp?type=node&node=4662243&i=4>> > > > Sent: Thursday, March 21, 2013 3:03 PM > > Subject: Re: [R] cumulative sum by group and under some criteria > > > > > > Hi, > > > > I used a computer cluster and output the file attached here, I need to > > read the file in R. I tried to use read.table, but it seems that the > format > > is not recognized by R, could you help? > > > > > Rout2122.text (528 bytes) < > http://r.789695.n4.nabble.com/attachment/4662237/0/Rout2122.text> > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/cumulative-sum-by-group-and-under-some-criteria-tp4657074p4662237.html > Sent from the R help mailing list archive at Nabble.com. > [[alternative HTML version deleted]] > > ______________________________________________ > [hidden email] <http://user/SendEmail.jtp?type=node&node=4662243&i=5>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. > > ______________________________________________ > [hidden email] <http://user/SendEmail.jtp?type=node&node=4662243&i=6>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. > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://r.789695.n4.nabble.com/cumulative-sum-by-group-and-under-some-criteria-tp4657074p4662243.html > To unsubscribe from cumulative sum by group and under some criteria, click > here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4657074&code=WmpvYW5uYTIwMTNAZ21haWwuY29tfDQ2NTcwNzR8LTE3NTE1MDA0MzY=> > . > NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> > Routallnew.txt (12K) <http://r.789695.n4.nabble.com/attachment/4662393/0/Routallnew.txt> -- View this message in context: http://r.789695.n4.nabble.com/cumulative-sum-by-group-and-under-some-criteria-tp4657074p4662393.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]] ______________________________________________ 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.