[R] chunk row to new table/file

David Winsemius dwinsemius at comcast.net
Tue Sep 18 03:52:21 CEST 2012


On Sep 17, 2012, at 6:27 PM, s.s.m. fauzi wrote:

> I have big .csv file. I would like to filter that file into a new table.
> 
> 
> For example, I have .csv file as below:
> 
> 
> 
> 
>       f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
>    t1  1  0  1   0  1  0   0  0   0    1
>    t2  1  0  0   0  0  1   1  1   1    1
>    t3  0  0  0   0  0  0   0  0   0    0
>    t4  1  0  0   0  1  0   0  0   0    0
>    t5  0  0  0   0  0  0   0  0   0    0
>    t6  0  0  0   0  0  0   0  0   0    0

Answered on SO where this all began. In R-help you are asked not to cross-post.
http://stackoverflow.com/questions/12453483/creating-new-table-from-a-big-csv-table/12468243#comment16773052_12468243-- 
David.
> 
> 1. I have a table (as above)
> 
> 2. What I want to do is, I want to chunk a new table for each row (meaning
> that, I will have new table for row t1, new table for row t2, new table for
> row t3 and etc)
> 
> 3. To develop new table for each row, there is a condition that need to
> meet.  The row should be grouped with other row which have the same value
> in column
> (as in my example, row t1,t2,t4 should be grouped together because value in
> column f1 have the same value (which is 1) with the value in f1 for row t2
> and t4, also value in f5 is equal with the value in f5 for row t4, and
> value in f11 is equal with the value in f11 for row t2). Output for should
> be like this:
> 
> 
>           f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
>        t1  1  0  1   0  1  0   0  0   0    1
>        t2  1  0  0   0  0  1   1  1   1    1
>        t4  1  0  0   0  1  0   0  0   0    0
> 
> 4. Also as we can see from the above table, t2 also should have another
> table because value in f1 in t1 and value f1 in t4 is equal. However, t2
> should not consider t1. Output should be like this:
> 
>          f1 f2  f3 f4  f5  f6 f7 f9  f10  f11
>        t2  1  0  0   0  0  1   1  1   1    1
>        t4  1  0  0   0  1  0   0  0   0    0
> 
> 
> 
> 
> New table(s) (with row and column header) should be then saved in a new .
> csvfile.
> 
> Appreciate help from the expert!
> 
> 	[[alternative HTML version deleted]]
-- 

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list