On Tue, Sep 8, 2009 at 12:53 PM, Lauri Nikkinen<lauri.nikki...@iki.fi> 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?
?read.fwf Read Fixed Width Format Files Description: Read a table of *f*ixed *w*idth *f*ormatted data into a 'data.frame'. Usage: read.fwf(file, widths, header = FALSE, sep = "\t", skip = 0, row.names, col.names, n = -1, buffersize = 2000, ...) ______________________________________________ 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.