On Tue, Sep 08, 2009 at 02:53:11PM +0300, Lauri Nikkinen wrote: > I have a text file similar to this (separated by spaces): > > x <- "DF12 This is an example 1 This > DF12 This is an 1232 This is > DF14 This is 12334 This is an > DF15 This 23 This is an example > " > > and I know the field lengths of each variable (there is 5 variables in > this data set), which are: > > varlength <- c(2, 2, 18, 5, 18) > > How can I import this kind of data into R, using the varlength > variable as an field separator indicator?
I am not totally sure what exaclty the expected result is. From your description I got the impression that your data file uses a mixture of separation characters and fixed-width formatting. Maybe I misinterpreted your example. Have a look at read.fwf() an if that does not solve your problem maybe explain the Structure and expected result a little further. cu Philipp -- Dr. Philipp Pagel Lehrstuhl für Genomorientierte Bioinformatik Technische Universität München Wissenschaftszentrum Weihenstephan 85350 Freising, Germany http://webclu.bio.wzw.tum.de/~pagel/ ______________________________________________ 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.