Hi,
Try this:
con<-file("Routallnew.txt")
 Lines1<- readLines(con)
 close(con)
indx<-rep(rep(c(TRUE,FALSE),each=2),24)
Lines2<-Lines1[!grepl("[A-Za-z]",Lines1)]
res<-read.table(text=paste(gsub("^\\s+","",Lines2[indx]),gsub("^\\s+","",Lines2[!indx])),sep="",header=FALSE)
nm1<-unlist(strsplit(gsub("^ 
+","",paste(Lines1[grepl("[A-Za-z]",Lines1)][1:2],collapse=" "))," "))
colnames(res)<- nm1[nm1!=""]
head(res)
#  m1 n1  m  n cterm1_P0L cterm1_P0H  c11  c12   c1   c2 alpha beta   T_error  N
#1 13  5 17  9  0.7851203  0.6689925 0.03 0.03 0.15 0.15   0.1  0.2 0.3669373 26
#2 13  5 17  9  0.7851203  0.6689925 0.03 0.03 0.15 0.15   0.1  0.2 0.3669373 26
#3  9  5 13 11  0.6302494  0.4876750 0.03 0.03 0.15 0.20   0.1  0.2 0.4137296 24
#4  9  5 13 11  0.6302494  0.4876750 0.03 0.03 0.15 0.20   0.1  0.2 0.4137296 24
#5  9  5 13 11  0.6302494  0.4876750 0.03 0.03 0.15 0.25   0.1  0.2 0.4782406 24
#6  9  5 13 11  0.6302494  0.4876750 0.03 0.03 0.15 0.25   0.1  0.2 0.4782406 24
#        EN         BH        BL         AH         AL
#1 20.18355 0.07718537 0.1865207 0.08079875 0.02243240
#2 20.18355 0.07718537 0.1865207 0.08079875 0.02243240
#3 18.55295 0.08482219 0.1996013 0.09569044 0.03361565
#4 18.55295 0.08482219 0.1996013 0.09569044 0.03361565
#5 18.55295 0.19596330 0.1996013 0.04906038 0.03361565
#6 18.55295 0.19596330 0.1996013 0.04906038 0.03361565

A.K.





________________________________
From: Joanna Zhang <zjoanna2...@gmail.com>
To: arun <smartpink...@yahoo.com> 
Sent: Monday, March 25, 2013 11:19 AM
Subject: Read text file in R


Hi Arun,

I just sent  you a text file via R, but I think it is being held for moderator 
approval. I attached the final output file here, could you help me read it in R 
when you have time?

______________________________________________
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.

Reply via email to