Skip to content
Prev 320133 / 398503 Next

Reading dataset in R

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.