Hi, No problem.
dat1 <- subset(head(read.table("temp1.txt",skip=6,sep=",",header=FALSE,fill=TRUE,stringsAsFactors=FALSE),-1),select=1:4) dat1$V1 <- as.numeric(dat1$V1) str(dat1) #'data.frame': 96409 obs. of 4 variables: # $ V1: num 891231 900101 900101 900101 900101 ... # $ V2: int 2400 100 200 300 400 500 600 700 800 900 ... # $ V3: num -1.5 -1.4 -1.6 -1.7 -2.1 -2.3 -2.4 -2.5 -2.6 -2.8 ... # $ V4: num -0.21 -0.25 -0.28 -0.25 -0.1 ... head(dat1) # V1 V2 V3 V4 #1 891231 2400 -1.5 -0.2100000 #2 900101 100 -1.4 -0.2500000 #3 900101 200 -1.6 -0.2800000 #4 900101 300 -1.7 -0.2500000 #5 900101 400 -2.1 -0.0999999 #6 900101 500 -2.3 -0.0899999 tail(dat1,2) # V1 V2 V3 V4 #96408 1230 2300 -1.215 1.308 #96409 1230 2400 -1.485 0.377 A.K. On Saturday, October 19, 2013 7:17 AM, Kumar Raj <pollar...@gmail.com> wrote: Hi , Thanks for your effort. Now your new code works for the sample data. The earlier one did not work for sample and whole data set. I have attached part of the real data as it is publicly available . As you could see in the data EOF and all other information in the header is downloaded as part of the data. Thanks On 19 October 2013 04:30, <smartpink...@yahoo.com> wrote: Hi, >If the data starts on the lines as you described, I am not sure why you have >EOF and all the other things. It is confusing. Anyway, it is not clear what >you meant by it doesn't work. Is it on the full dataset or on the sample set >I showed? It worked for me. I can check your dataset or a sample of the data >in its original .txt format if you can email me. > >Regards. > > ><quote author='Anuma'> >Thanks, but the code does not work. I received an error like this one " >Error in read.table(text = gsub("#|,$", "", temp[grepl(",", temp)][-1]), : > duplicate 'row.names' are not allowed". > >In the sample data that I have pasted on this page the data has four columns >and it starts at the following line "891231, 2400, -1.5, -0.21, ". Anything >before that is uninteresting for me. ></quote> >Quoted from: >http://r.789695.n4.nabble.com/read-table-and-import-of-a-text-file-tp4678525p4678571.html > > >_____________________________________ >Sent from http://r.789695.n4.nabble.com > > ______________________________________________ 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.