[R] How to filter information from a big .csv table into a new table

arun smartpink111 at yahoo.com
Mon Sep 17 04:38:27 CEST 2012



Hi,
I guess this is what you are looking for:
dat1<-read.table(text="
    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
",sep="",header=TRUE)
 

dat1[dat1$f1==1,]
#   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
A.K.

________________________________
From: s.s.m. fauzi <ssmfone at gmail.com>
To: r-help at r-project.org 
Sent: Sunday, September 16, 2012 10:30 PM
Subject: [R] How to filter information from a big .csv table into a new table

Hi,

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



I want to filter the table above to another table as below. It will only show
an information which have a dependency.


As you can see below, t1 has a dependency with t2 and t4, because f1 has a same
value (value 1) with t2 and t4.

Also, f5 has a same value with f5 in t4.

Also, f10 has a same value with f10 in t2.



     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



New table (with row and column header) should be then saved in a new .
csvfile.

    [[alternative HTML version deleted]]

______________________________________________
R-help at 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.




More information about the R-help mailing list