[R] Data separated by spaces, getting data into R using field lengths
Philipp Pagel
p.pagel at wzw.tum.de
Tue Sep 8 14:33:24 CEST 2009
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/
More information about the R-help
mailing list