RE: [R] Read a dataset with different lengths

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Tue 22 Mar 2005 - 04:54:22 EST


If the file is formatted as you've shown, you should be able to read it with read.fwf().

Andy

> From: Xiyan Lon
>
> Dear useR again,
> How can I read a dataset if lines in dataset did not have same
> elements (have different lengths), For example:
>
> 1 2, 4, 16, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1
> 2 2, 13, 5, 1, 1, 3, 1, 1, 15, 5, 1, 1, 14, 1, 1
> 3 4, 5, 11, 1, 1, 6, 1, 1, 5, 14, 1, 1, 15, 1, 1
> 4 2, 5, 9, 1, 1, 14, 1, 1, 8, 16, 1, 1, 13, 1, 1
> 5 3, 7, 14, 1, 1, 14, 1, 1, 5, 21, 1, 1, 8, 1, 1
> 6 6, 3, 1, 12, 1, 1, 5, 8, 1, 1, 15, 1, 1
> 7 6, 3, 1, 11, 1, 1, 10, 7, 1, 1, 21, 1, 1
> 8 21, 20, 9, 1, 1, 6, 1, 1, 13, 10, 1, 1, 1
> 9 5, 7, 21, 1, 1, 13, 1, 1, 14, 2, 1, 1, 6, 1, 1
> 10 8, 14, 10, 1, 1, 5, 1, 1, 10, 5, 1, 1, 5, 1, 1
> 11 5, 20, 17, 1, 1, 19, 1, 1, 14, 7, 1, 1, 6, 1, 1
> 12 7, 4, 11, 1, 1, 2, 1, 1, 5, 13, 1, 1, 14, 1, 1
> 13 7, 14, 13, 1, 1, 6, 1, 1, 13, 16, 1, 1, 17, 1, 1
> 14 7, 14, 5, 1, 1, 5, 1, 1, 5, 17, 1, 1, 17, 1, 1
> 15 3, 9, 12, 1, 1, 18, 1, 1, 6, 1, 4, 1, 1
> 16 7, 10, 5, 1, 1, 12, 1, 1, 5, 17, 1, 1, 13, 1, 1
> 17 12, 8, 16, 1, 1, 5, 1, 1, 8, 10, 1, 1, 14, 1, 1
> 18 5, 11, 7, 1, 1, 5, 1, 1, 18, 13, 1, 1, 17, 1, 1
> 19 7, 13, 8, 1, 1, 14, 1, 1, 5, 17, 1, 1, 13, 1, 1
> 20 7, 18, 21, 1, 1, 16, 1, 1, 5, 17, 1, 1, 13, 1, 1
>
> I know that in BioC package rmutil have a function (read.list) to
> handle different lengths sets of lines but it did not work.
> > library(rmutil)
> Error in library(rmutil) : 'rmutil' is not a valid package --
> installed < 2.0.0?
> >

>
> Are there any others function to handle this.
>
> Best regards
> Xiyan Lon
>
> > version
> _
> platform i386-pc-mingw32
> arch i386
> os mingw32
> system i386, mingw32
> status
> major 2
> minor 0.1
> year 2004
> month 11
> day 15
> language R
> >
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Mar 22 05:11:27 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:52 EST